diff options
-rw-r--r-- | nvim.lua (renamed from init.lua) | 227 |
1 files changed, 131 insertions, 96 deletions
@@ -4,11 +4,11 @@ | |||
4 | ==================== READ THIS BEFORE CONTINUING ==================== | 4 | ==================== READ THIS BEFORE CONTINUING ==================== |
5 | ===================================================================== | 5 | ===================================================================== |
6 | 6 | ||
7 | -- Kickstart.nvim is *not* a distribution. | 7 | Kickstart.nvim is *not* a distribution. |
8 | -- | 8 | |
9 | Kickstart.nvim is a template for your own configuration. | 9 | Kickstart.nvim is a template for your own configuration. |
10 | The goal is that you can read every line of code, top-to-bottom, and understand | 10 | The goal is that you can read every line of code, top-to-bottom, understand |
11 | what your configuration is doing. | 11 | what your configuration is doing, and modify it to suit your needs. |
12 | 12 | ||
13 | Once you've done that, you should start exploring, configuring and tinkering to | 13 | Once you've done that, you should start exploring, configuring and tinkering to |
14 | explore Neovim! | 14 | explore Neovim! |
@@ -17,7 +17,9 @@ Kickstart.nvim is a template for your own configuration. | |||
17 | a guide. One possible example: | 17 | a guide. One possible example: |
18 | - https://learnxinyminutes.com/docs/lua/ | 18 | - https://learnxinyminutes.com/docs/lua/ |
19 | 19 | ||
20 | |||
20 | And then you can explore or search through `:help lua-guide` | 21 | And then you can explore or search through `:help lua-guide` |
22 | - https://neovim.io/doc/user/lua-guide.html | ||
21 | 23 | ||
22 | 24 | ||
23 | Kickstart Guide: | 25 | Kickstart Guide: |
@@ -35,15 +37,11 @@ I hope you enjoy your Neovim journey, | |||
35 | 37 | ||
36 | P.S. You can delete this when you're done too. It's your config now :) | 38 | P.S. You can delete this when you're done too. It's your config now :) |
37 | --]] | 39 | --]] |
38 | -- [[ General Config ]] | ||
39 | vim.cmd('source ' .. '~/.vim/vim-init/init/init-basic.vim') | ||
40 | vim.cmd('source ' .. '~/.vim/vim-init/init/init-keymaps.vim') | ||
41 | |||
42 | 40 | ||
43 | -- Install package manager | 41 | -- Install package manager |
44 | -- https://github.com/folke/lazy.nvim | 42 | -- https://github.com/folke/lazy.nvim |
45 | -- `:help lazy.nvim.txt` for more info | 43 | -- `:help lazy.nvim.txt` for more info |
46 | local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' | 44 | local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' |
47 | if not vim.loop.fs_stat(lazypath) then | 45 | if not vim.loop.fs_stat(lazypath) then |
48 | vim.fn.system { | 46 | vim.fn.system { |
49 | 'git', | 47 | 'git', |
@@ -64,6 +62,10 @@ vim.opt.runtimepath:prepend(lazypath) | |||
64 | require('lazy').setup({ | 62 | require('lazy').setup({ |
65 | -- NOTE: First, some plugins that don't require any configuration | 63 | -- NOTE: First, some plugins that don't require any configuration |
66 | 64 | ||
65 | -- Git related plugins | ||
66 | 'tpope/vim-fugitive', | ||
67 | 'tpope/vim-rhubarb', | ||
68 | |||
67 | -- Detect tabstop and shiftwidth automatically | 69 | -- Detect tabstop and shiftwidth automatically |
68 | 'tpope/vim-sleuth', | 70 | 'tpope/vim-sleuth', |
69 | 71 | ||
@@ -73,6 +75,10 @@ require('lazy').setup({ | |||
73 | -- For beancount | 75 | -- For beancount |
74 | 'nathangrigg/vim-beancount', | 76 | 'nathangrigg/vim-beancount', |
75 | 77 | ||
78 | -- For surrounding | ||
79 | 'machakann/vim-sandwich', | ||
80 | |||
81 | |||
76 | -- NOTE: This is where your plugins related to LSP can be installed. | 82 | -- NOTE: This is where your plugins related to LSP can be installed. |
77 | -- The configuration is done below. Search for lspconfig to find it below. | 83 | -- The configuration is done below. Search for lspconfig to find it below. |
78 | { | 84 | { |
@@ -85,7 +91,7 @@ require('lazy').setup({ | |||
85 | 91 | ||
86 | -- Useful status updates for LSP | 92 | -- Useful status updates for LSP |
87 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` | 93 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` |
88 | { 'j-hui/fidget.nvim', opts = {} }, | 94 | { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, |
89 | 95 | ||
90 | -- Additional lua configuration, makes nvim stuff amazing! | 96 | -- Additional lua configuration, makes nvim stuff amazing! |
91 | 'folke/neodev.nvim', | 97 | 'folke/neodev.nvim', |
@@ -95,20 +101,23 @@ require('lazy').setup({ | |||
95 | { | 101 | { |
96 | -- Autocompletion | 102 | -- Autocompletion |
97 | 'hrsh7th/nvim-cmp', | 103 | 'hrsh7th/nvim-cmp', |
98 | dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, | 104 | dependencies = { |
105 | -- Snippet Engine & its associated nvim-cmp source | ||
106 | 'L3MON4D3/LuaSnip', | ||
107 | 'saadparwaiz1/cmp_luasnip', | ||
108 | |||
109 | -- Adds LSP completion capabilities | ||
110 | 'hrsh7th/cmp-nvim-lsp', | ||
111 | |||
112 | -- Adds a number of user-friendly snippets | ||
113 | 'rafamadriz/friendly-snippets', | ||
114 | }, | ||
99 | }, | 115 | }, |
100 | 116 | ||
101 | -- Useful plugin to show you pending keybinds. | 117 | -- Useful plugin to show you pending keybinds. |
118 | { 'folke/which-key.nvim', opts = {} }, | ||
102 | { | 119 | { |
103 | 'folke/which-key.nvim', | 120 | -- Adds git related signs to the gutter, as well as utilities for managing changes |
104 | opts = { | ||
105 | triggers_blacklist = { | ||
106 | n = { ":" }, -- ignore : in normal mode | ||
107 | }, | ||
108 | } | ||
109 | }, | ||
110 | { | ||
111 | -- Adds git releated signs to the gutter, as well as utilities for managing changes | ||
112 | 'lewis6991/gitsigns.nvim', | 121 | 'lewis6991/gitsigns.nvim', |
113 | opts = { | 122 | opts = { |
114 | -- See `:help gitsigns.txt` | 123 | -- See `:help gitsigns.txt` |
@@ -119,16 +128,32 @@ require('lazy').setup({ | |||
119 | topdelete = { text = '‾' }, | 128 | topdelete = { text = '‾' }, |
120 | changedelete = { text = '~' }, | 129 | changedelete = { text = '~' }, |
121 | }, | 130 | }, |
131 | on_attach = function(bufnr) | ||
132 | vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, | ||
133 | { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) | ||
134 | vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) | ||
135 | vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) | ||
136 | end, | ||
122 | }, | 137 | }, |
123 | }, | 138 | }, |
124 | 139 | ||
125 | { | 140 | { |
141 | -- Theme inspired by Atom | ||
142 | 'navarasu/onedark.nvim', | ||
143 | priority = 1000, | ||
144 | config = function() | ||
145 | vim.cmd.colorscheme 'onedark' | ||
146 | end, | ||
147 | }, | ||
148 | |||
149 | { | ||
126 | -- Set lualine as statusline | 150 | -- Set lualine as statusline |
127 | 'nvim-lualine/lualine.nvim', | 151 | 'nvim-lualine/lualine.nvim', |
128 | -- See `:help lualine.txt` | 152 | -- See `:help lualine.txt` |
129 | opts = { | 153 | opts = { |
130 | options = { | 154 | options = { |
131 | icons_enabled = false, | 155 | icons_enabled = false, |
156 | theme = 'onedark', | ||
132 | component_separators = '|', | 157 | component_separators = '|', |
133 | section_separators = { left = '', right = '' }, | 158 | section_separators = { left = '', right = '' }, |
134 | }, | 159 | }, |
@@ -147,32 +172,39 @@ require('lazy').setup({ | |||
147 | }, | 172 | }, |
148 | 173 | ||
149 | -- "gc" to comment visual regions/lines | 174 | -- "gc" to comment visual regions/lines |
150 | { | 175 | { 'numToStr/Comment.nvim', opts = {} }, |
151 | 'numToStr/Comment.nvim', | 176 | -- Another config |
152 | opts = { | 177 | -- { |
153 | opleader = { | 178 | -- 'numToStr/Comment.nvim', |
154 | ---Line-comment keymap | 179 | -- opts = { |
155 | line = '<C-_>', | 180 | -- opleader = { |
156 | ---Block-comment keymap | 181 | -- ---Line-comment keymap |
157 | block = 'gb', | 182 | -- line = '<C-_>', |
158 | }, | 183 | -- ---Block-comment keymap |
159 | } | 184 | -- block = 'gb', |
160 | }, | 185 | -- }, |
186 | -- }, | ||
161 | 187 | ||
162 | -- Fuzzy Finder (files, lsp, etc) | ||
163 | { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, | ||
164 | 188 | ||
165 | -- Fuzzy Finder Algorithm which requires local dependencies to be built. | 189 | -- Fuzzy Finder (files, lsp, etc) |
166 | -- Only load if `make` is available. Make sure you have the system | ||
167 | -- requirements installed. | ||
168 | { | 190 | { |
169 | 'nvim-telescope/telescope-fzf-native.nvim', | 191 | 'nvim-telescope/telescope.nvim', |
170 | -- NOTE: If you are having trouble with this installation, | 192 | branch = '0.1.x', |
171 | -- refer to the README for telescope-fzf-native for more instructions. | 193 | dependencies = { |
172 | build = 'make', | 194 | 'nvim-lua/plenary.nvim', |
173 | cond = function() | 195 | -- Fuzzy Finder Algorithm which requires local dependencies to be built. |
174 | return vim.fn.executable 'make' == 1 | 196 | -- Only load if `make` is available. Make sure you have the system |
175 | end, | 197 | -- requirements installed. |
198 | { | ||
199 | 'nvim-telescope/telescope-fzf-native.nvim', | ||
200 | -- NOTE: If you are having trouble with this installation, | ||
201 | -- refer to the README for telescope-fzf-native for more instructions. | ||
202 | build = 'make', | ||
203 | cond = function() | ||
204 | return vim.fn.executable 'make' == 1 | ||
205 | end, | ||
206 | }, | ||
207 | }, | ||
176 | }, | 208 | }, |
177 | 209 | ||
178 | { | 210 | { |
@@ -181,7 +213,7 @@ require('lazy').setup({ | |||
181 | dependencies = { | 213 | dependencies = { |
182 | 'nvim-treesitter/nvim-treesitter-textobjects', | 214 | 'nvim-treesitter/nvim-treesitter-textobjects', |
183 | }, | 215 | }, |
184 | build = ":TSUpdate", | 216 | build = ':TSUpdate', |
185 | }, | 217 | }, |
186 | 218 | ||
187 | -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart | 219 | -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart |
@@ -190,33 +222,34 @@ require('lazy').setup({ | |||
190 | -- require 'kickstart.plugins.autoformat', | 222 | -- require 'kickstart.plugins.autoformat', |
191 | -- require 'kickstart.plugins.debug', | 223 | -- require 'kickstart.plugins.debug', |
192 | 224 | ||
193 | 'machakann/vim-sandwich', | 225 | -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` |
194 | -- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua` | ||
195 | -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping | 226 | -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping |
196 | -- up-to-date with whatever is in the kickstart repo. | 227 | -- up-to-date with whatever is in the kickstart repo. |
228 | -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. | ||
197 | -- | 229 | -- |
198 | -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins | 230 | -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins |
199 | -- | 231 | -- { import = 'custom.plugins' }, |
200 | -- An additional note is that if you only copied in the `init.lua`, you can just comment this line | ||
201 | -- to get rid of the warning telling you that there are not plugins in `lua/custom/plugins/`. | ||
202 | --{ import = 'custom.plugins' }, | ||
203 | }, {}) | 232 | }, {}) |
204 | 233 | ||
205 | |||
206 | -- [[ Setting options ]] | 234 | -- [[ Setting options ]] |
207 | -- See `:help vim.o` | 235 | -- See `:help vim.o` |
208 | 236 | ||
209 | -- Enable mouse mode | ||
210 | -- vim.o.mouse = 'a' | ||
211 | |||
212 | -- Sync clipboard between OS and Neovim. | 237 | -- Sync clipboard between OS and Neovim. |
213 | -- Remove this option if you want your OS clipboard to remain independent. | 238 | -- Remove this option if you want your OS clipboard to remain independent. |
214 | -- See `:help 'clipboard'` | 239 | -- See `:help 'clipboard'` |
240 | |||
215 | -- vim.o.clipboard = 'unnamedplus' | 241 | -- vim.o.clipboard = 'unnamedplus' |
216 | 242 | ||
217 | -- Enable break indent | 243 | -- Enable break indent |
218 | vim.o.breakindent = true | 244 | vim.o.breakindent = true |
219 | 245 | ||
246 | -- Save undo history | ||
247 | vim.o.undofile = true | ||
248 | |||
249 | -- Case-insensitive searching UNLESS \C or capital in search | ||
250 | vim.o.ignorecase = true | ||
251 | vim.o.smartcase = true | ||
252 | |||
220 | -- Keep signcolumn on by default | 253 | -- Keep signcolumn on by default |
221 | vim.wo.signcolumn = 'yes' | 254 | vim.wo.signcolumn = 'yes' |
222 | 255 | ||
@@ -229,19 +262,28 @@ vim.o.timeoutlen = 300 | |||
229 | vim.o.completeopt = 'menuone,noselect' | 262 | vim.o.completeopt = 'menuone,noselect' |
230 | 263 | ||
231 | -- NOTE: You should make sure your terminal supports this | 264 | -- NOTE: You should make sure your terminal supports this |
232 | -- vim.o.termguicolors = true | 265 | vim.o.termguicolors = true |
233 | |||
234 | 266 | ||
235 | -- [[ Basic Keymaps ]] | 267 | -- [[ Basic Keymaps ]] |
236 | 268 | ||
237 | -- Keymaps for better default experience | 269 | -- Keymaps for better default experience |
238 | -- See `:help vim.keymap.set()` | 270 | -- See `:help vim.keymap.set()` |
271 | vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) | ||
239 | 272 | ||
240 | -- Use suda.vim to run sudo, or terminal prompt fails | 273 | -- Use suda.vim to run sudo, or terminal prompt fails |
241 | -- See more details at https://github.com/neovim/neovim/issues/1716 | 274 | -- See more details at https://github.com/neovim/neovim/issue |
242 | vim.cmd("command! W execute 'SudaWrite %'") | 275 | vim.cmd("command! W execute 'SudaWrite %'") |
243 | 276 | ||
244 | 277 | ||
278 | -- [[ Configure lualine ]] | ||
279 | -- Change the background of lualine_b section for normal mode | ||
280 | local custom_wombat = require 'lualine.themes.wombat' | ||
281 | custom_wombat.normal.b.bg = '#a8a8a8' | ||
282 | custom_wombat.normal.b.fg = '#444444' | ||
283 | require('lualine').setup { | ||
284 | options = { theme = custom_wombat }, | ||
285 | } | ||
286 | |||
245 | -- [[ Highlight on yank ]] | 287 | -- [[ Highlight on yank ]] |
246 | -- See `:help vim.highlight.on_yank()` | 288 | -- See `:help vim.highlight.on_yank()` |
247 | local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) | 289 | local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) |
@@ -253,17 +295,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { | |||
253 | pattern = '*', | 295 | pattern = '*', |
254 | }) | 296 | }) |
255 | 297 | ||
256 | |||
257 | -- [[ Configure lualine ]] | ||
258 | -- Change the background of lualine_b section for normal mode | ||
259 | local custom_wombat = require 'lualine.themes.wombat' | ||
260 | custom_wombat.normal.b.bg = '#a8a8a8' | ||
261 | custom_wombat.normal.b.fg = '#444444' | ||
262 | require('lualine').setup { | ||
263 | options = { theme = custom_wombat }, | ||
264 | } | ||
265 | |||
266 | |||
267 | -- [[ Configure Telescope ]] | 298 | -- [[ Configure Telescope ]] |
268 | -- See `:help telescope` and `:help telescope.setup()` | 299 | -- See `:help telescope` and `:help telescope.setup()` |
269 | require('telescope').setup { | 300 | require('telescope').setup { |
@@ -282,6 +313,9 @@ require('telescope').setup { | |||
282 | }, | 313 | }, |
283 | }, | 314 | }, |
284 | pickers = { | 315 | pickers = { |
316 | oldfiles = { | ||
317 | previewer = true, | ||
318 | }, | ||
285 | buffers = { | 319 | buffers = { |
286 | show_all_buffers = true, | 320 | show_all_buffers = true, |
287 | sort_lastused = true, | 321 | sort_lastused = true, |
@@ -308,7 +342,7 @@ vim.keymap.set('n', '<leader>q', require('telescope.builtin').buffers, { desc = | |||
308 | vim.keymap.set('n', '<leader>/', function() | 342 | vim.keymap.set('n', '<leader>/', function() |
309 | -- You can pass additional configuration to telescope to change theme, layout, etc. | 343 | -- You can pass additional configuration to telescope to change theme, layout, etc. |
310 | require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { | 344 | require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { |
311 | -- winblend = 10, | 345 | --winblend = 10, |
312 | previewer = false, | 346 | previewer = false, |
313 | }) | 347 | }) |
314 | end, { desc = '[/] Fuzzily search in current buffer' }) | 348 | end, { desc = '[/] Fuzzily search in current buffer' }) |
@@ -320,7 +354,6 @@ vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { de | |||
320 | vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) | 354 | vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) |
321 | vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) | 355 | vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) |
322 | 356 | ||
323 | |||
324 | -- [[ Configure Treesitter ]] | 357 | -- [[ Configure Treesitter ]] |
325 | -- See `:help nvim-treesitter` | 358 | -- See `:help nvim-treesitter` |
326 | require('nvim-treesitter.configs').setup { | 359 | require('nvim-treesitter.configs').setup { |
@@ -331,7 +364,7 @@ require('nvim-treesitter.configs').setup { | |||
331 | auto_install = false, | 364 | auto_install = false, |
332 | 365 | ||
333 | highlight = { enable = true }, | 366 | highlight = { enable = true }, |
334 | indent = { enable = true, disable = { 'python' } }, | 367 | indent = { enable = true }, |
335 | incremental_selection = { | 368 | incremental_selection = { |
336 | enable = true, | 369 | enable = true, |
337 | keymaps = { | 370 | keymaps = { |
@@ -388,12 +421,12 @@ require('nvim-treesitter.configs').setup { | |||
388 | } | 421 | } |
389 | 422 | ||
390 | -- Diagnostic keymaps | 423 | -- Diagnostic keymaps |
391 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) | 424 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) |
392 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) | 425 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) |
393 | vim.keymap.set('n', '<leader>E', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) | 426 | vim.keymap.set('n', '<leader>E', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) |
394 | vim.keymap.set('n', '<leader>Q', vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) | 427 | vim.keymap.set('n', '<leader>Q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) |
395 | 428 | ||
396 | -- LSP settings. | 429 | -- [[ Configure LSP ]] |
397 | -- This function gets run when an LSP connects to a particular buffer. | 430 | -- This function gets run when an LSP connects to a particular buffer. |
398 | local on_attach = function(_, bufnr) | 431 | local on_attach = function(_, bufnr) |
399 | -- NOTE: Remember that lua is a real programming language, and as such it is possible | 432 | -- NOTE: Remember that lua is a real programming language, and as such it is possible |
@@ -418,17 +451,17 @@ local on_attach = function(_, bufnr) | |||
418 | nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') | 451 | nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') |
419 | nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') | 452 | nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') |
420 | nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') | 453 | nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') |
421 | nmap('<leader><leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') | 454 | nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') |
422 | 455 | ||
423 | -- See `:help K` for why this keymap | 456 | -- See `:help K` for why this keymap |
424 | nmap('K', vim.lsp.buf.hover, 'Hover Documentation') | 457 | nmap('K', vim.lsp.buf.hover, 'Hover Documentation') |
425 | nmap('<leader>k', vim.lsp.buf.signature_help, 'Signature Documentation') | 458 | nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') |
426 | 459 | ||
427 | -- Lesser used LSP functionality | 460 | -- Lesser used LSP functionality |
428 | nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') | 461 | nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') |
429 | nmap('<leader><leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') | 462 | nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') |
430 | nmap('<leader><leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') | 463 | nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') |
431 | nmap('<leader><leader>wl', function() | 464 | nmap('<leader>wl', function() |
432 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) | 465 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) |
433 | end, '[W]orkspace [L]ist Folders') | 466 | end, '[W]orkspace [L]ist Folders') |
434 | 467 | ||
@@ -440,20 +473,20 @@ local on_attach = function(_, bufnr) | |||
440 | end | 473 | end |
441 | 474 | ||
442 | -- Enable the following language servers | 475 | -- Enable the following language servers |
443 | -- Read Doc page for more configuration: | 476 | -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. |
444 | -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md | ||
445 | -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. | ||
446 | -- | 477 | -- |
447 | -- Add any additional override configuration in the following tables. They will be passed to | 478 | -- Add any additional override configuration in the following tables. They will be passed to |
448 | -- the `settings` field of the server config. You must look up that documentation yourself. | 479 | -- the `settings` field of the server config. You must look up that documentation yourself. |
480 | -- | ||
481 | -- If you want to override the default filetypes that your language server will attach to you can | ||
482 | -- define the property 'filetypes' to the map in question. | ||
449 | local servers = { | 483 | local servers = { |
450 | -- clangd = {}, | 484 | -- clangd = {}, |
451 | -- gopls = {}, | 485 | -- gopls = {}, |
452 | bashls = {}, | 486 | -- pyright = {}, |
453 | marksman = {}, | 487 | -- rust_analyzer = {}, |
454 | html = {}, | 488 | -- tsserver = {}, |
455 | pyright = {}, | 489 | -- html = { filetypes = { 'html', 'twig', 'hbs'} }, |
456 | rust_analyzer = {}, | ||
457 | tsserver = {}, | 490 | tsserver = {}, |
458 | beancount = { | 491 | beancount = { |
459 | filetypes = { "beancount", "bean" }, | 492 | filetypes = { "beancount", "bean" }, |
@@ -487,14 +520,16 @@ mason_lspconfig.setup_handlers { | |||
487 | capabilities = capabilities, | 520 | capabilities = capabilities, |
488 | on_attach = on_attach, | 521 | on_attach = on_attach, |
489 | settings = servers[server_name], | 522 | settings = servers[server_name], |
523 | filetypes = (servers[server_name] or {}).filetypes, | ||
490 | } | 524 | } |
491 | end, | 525 | end |
492 | } | 526 | } |
493 | 527 | ||
494 | -- nvim-cmp setup | 528 | -- [[ Configure nvim-cmp ]] |
529 | -- See `:help cmp` | ||
495 | local cmp = require 'cmp' | 530 | local cmp = require 'cmp' |
496 | local luasnip = require 'luasnip' | 531 | local luasnip = require 'luasnip' |
497 | 532 | require('luasnip.loaders.from_vscode').lazy_load() | |
498 | luasnip.config.setup {} | 533 | luasnip.config.setup {} |
499 | 534 | ||
500 | cmp.setup { | 535 | cmp.setup { |
@@ -516,7 +551,7 @@ cmp.setup { | |||
516 | ['<Tab>'] = cmp.mapping(function(fallback) | 551 | ['<Tab>'] = cmp.mapping(function(fallback) |
517 | if cmp.visible() then | 552 | if cmp.visible() then |
518 | cmp.select_next_item() | 553 | cmp.select_next_item() |
519 | elseif luasnip.expand_or_jumpable() then | 554 | elseif luasnip.expand_or_locally_jumpable() then |
520 | luasnip.expand_or_jump() | 555 | luasnip.expand_or_jump() |
521 | else | 556 | else |
522 | fallback() | 557 | fallback() |
@@ -525,7 +560,7 @@ cmp.setup { | |||
525 | ['<S-Tab>'] = cmp.mapping(function(fallback) | 560 | ['<S-Tab>'] = cmp.mapping(function(fallback) |
526 | if cmp.visible() then | 561 | if cmp.visible() then |
527 | cmp.select_prev_item() | 562 | cmp.select_prev_item() |
528 | elseif luasnip.jumpable(-1) then | 563 | elseif luasnip.locally_jumpable(-1) then |
529 | luasnip.jump(-1) | 564 | luasnip.jump(-1) |
530 | else | 565 | else |
531 | fallback() | 566 | fallback() |