Mercurial > dotfiles
annotate dot_config/nvim/config.lua @ 408:4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sat, 17 Jul 2021 11:25:54 +0200 |
parents | 270a0f0f4c7f |
children | f0300cd1584c |
rev | line source |
---|---|
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
1 -- |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
2 -- Neovim dotfiles |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
3 -- |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
4 -- |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
5 local execute = vim.api.nvim_command |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
6 local fn = vim.fn |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
7 |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
8 -- Bootstrap package manager |
406 | 9 local install_path = fn.stdpath 'data' .. '/site/pack/packer/opt/packer.nvim' |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
10 |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
11 if fn.empty(fn.glob(install_path)) > 0 then |
380 | 12 execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
13 end |
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
14 |
325
ce396166d009
Move packer setup in a function, load on demand
zegervdv <zegervdv@me.com>
parents:
324
diff
changeset
|
15 -- Packer configuration is compiled and only needs to be loaded on changes |
380 | 16 vim.cmd 'packadd packer.nvim' |
325
ce396166d009
Move packer setup in a function, load on demand
zegervdv <zegervdv@me.com>
parents:
324
diff
changeset
|
17 |
372 | 18 require('packer').startup(function() |
380 | 19 use { 'wbthomason/packer.nvim', opt = true } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
20 |
372 | 21 -- General plugins |
380 | 22 use { 'tpope/vim-sensible' } |
23 use { 'tpope/vim-repeat' } | |
24 use { 'tpope/vim-rsi' } | |
25 use { 'sgur/vim-editorconfig' } | |
26 use { 'ShikChen/osc52.vim' } | |
27 use { 'einfachtoll/didyoumean' } | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
28 |
380 | 29 use { 'tpope/vim-obsession' } |
372 | 30 use { |
31 'tpope/vim-eunuch', | |
32 cmd = { | |
385 | 33 'Delete', |
372 | 34 'Unlink', |
35 'Move', | |
36 'Rename', | |
37 'Mkdir', | |
38 'Chmod', | |
385 | 39 'Cfind', |
40 'Clocate', | |
41 'Lfind', | |
42 'Llocate', | |
372 | 43 'SudoEdit', |
380 | 44 'SudoWrite', |
385 | 45 'Wall', |
380 | 46 }, |
372 | 47 } |
325
ce396166d009
Move packer setup in a function, load on demand
zegervdv <zegervdv@me.com>
parents:
324
diff
changeset
|
48 |
380 | 49 use { 'psliwka/vim-smoothie' } |
372 | 50 |
401
7948403a514c
Add plenary for local config scripts
Zeger Van de Vannet <zegervdv@me.com>
parents:
400
diff
changeset
|
51 use { 'nvim-lua/plenary.nvim' } |
7948403a514c
Add plenary for local config scripts
Zeger Van de Vannet <zegervdv@me.com>
parents:
400
diff
changeset
|
52 |
372 | 53 -- Spelling/autocorrection |
380 | 54 use { 'tpope/vim-abolish' } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
55 |
372 | 56 -- Git/VCS |
380 | 57 use { 'vim-scripts/gitignore' } |
58 use { 'sjl/splice.vim', opt = true, cmd = { 'SpliceInit' } } | |
59 use { 'tpope/vim-git' } | |
372 | 60 |
61 -- Comments | |
380 | 62 use { 'b3nj5m1n/kommentary' } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
63 |
372 | 64 -- Undoing |
380 | 65 use { 'sjl/gundo.vim', cmd = { 'GundoToggle' } } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
66 |
372 | 67 -- Parentheses etc |
380 | 68 use { 'tpope/vim-surround' } |
69 use { 'raimondi/delimitMate' } | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
70 |
372 | 71 -- Moving around within lines |
380 | 72 use { 'wellle/targets.vim', event = 'InsertEnter *' } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
73 |
372 | 74 -- Searching |
380 | 75 use { 'mhinz/vim-grepper', cmd = { 'Grepper' } } |
325
ce396166d009
Move packer setup in a function, load on demand
zegervdv <zegervdv@me.com>
parents:
324
diff
changeset
|
76 |
372 | 77 -- Keymaps TODO: to be removed when #13823 is merged |
406 | 78 use { |
79 'tjdevries/astronauta.nvim', | |
80 config = function() | |
81 require 'astronauta.keymap' | |
82 end, | |
83 } | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
84 |
399
59db83251de2
Add vim-fetch to open file patterns with linenrs/colnrs
zegervdv <zegervdv@me.com>
parents:
398
diff
changeset
|
85 -- Opening files |
59db83251de2
Add vim-fetch to open file patterns with linenrs/colnrs
zegervdv <zegervdv@me.com>
parents:
398
diff
changeset
|
86 use { 'wsdjeg/vim-fetch' } |
59db83251de2
Add vim-fetch to open file patterns with linenrs/colnrs
zegervdv <zegervdv@me.com>
parents:
398
diff
changeset
|
87 |
372 | 88 -- Indent lines |
89 use { | |
90 'lukas-reineke/indent-blankline.nvim', | |
380 | 91 config = function() |
92 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
372 | 93 vim.g.indent_blankline_show_first_indent_level = false |
94 end, | |
95 } | |
371
1dfda47d5d9e
Add more lua based plugins: lush, navigator, numb
zegervdv <zegervdv@me.com>
parents:
370
diff
changeset
|
96 |
372 | 97 -- Increment/decrement |
98 use { | |
99 'zegervdv/nrpattern.nvim', | |
100 requires = 'tpope/vim-repeat', | |
380 | 101 config = function() |
102 local nrpattern = require 'nrpattern' | |
103 local defaults = require 'nrpattern.default' | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
104 |
406 | 105 defaults[{ 'input', 'output' }] = { priority = 12, filetypes = { 'verilog', 'systemverilog' } } |
106 defaults[{ "'1", "'0" }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
372 | 107 |
108 nrpattern.setup(defaults) | |
109 end, | |
110 } | |
362 | 111 |
372 | 112 -- Tmux |
113 use { | |
114 'numtostr/navigator.nvim', | |
115 config = function() | |
116 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
362 | 117 |
372 | 118 local nnoremap = vim.keymap.nnoremap |
406 | 119 nnoremap { '<c-h>', require('Navigator').left, silent = true } |
120 nnoremap { '<c-j>', require('Navigator').down, silent = true } | |
121 nnoremap { '<c-k>', require('Navigator').up, silent = true } | |
122 nnoremap { '<c-l>', require('Navigator').right, silent = true } | |
372 | 123 end, |
380 | 124 requires = 'tjdevries/astronauta.nvim', |
390
bfaff08e7e54
Run navigator cfg after astronauta is loaded
Zeger Van de Vannet <zegervdv@me.com>
parents:
389
diff
changeset
|
125 after = 'astronauta.nvim', |
372 | 126 } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
127 |
372 | 128 -- Completion/snippets/LSP |
380 | 129 use { 'neovim/nvim-lspconfig' } |
372 | 130 use { |
131 'hrsh7th/nvim-compe', | |
380 | 132 config = function() |
406 | 133 require('compe').setup { |
380 | 134 enabled = true, |
135 autocomplete = true, | |
136 debug = false, | |
137 min_length = 1, | |
138 preselect = 'enable', | |
139 throttle_time = 80, | |
140 source_timeout = 1000, | |
141 incomplete_delay = 400, | |
142 max_abbr_width = 100, | |
143 max_kind_width = 100, | |
144 max_menu_width = 100, | |
145 documentation = true, | |
346
d717168f424f
Switch to nvim-compe for completion
zegervdv <zegervdv@me.com>
parents:
345
diff
changeset
|
146 |
372 | 147 source = { |
380 | 148 path = true, |
149 buffer = true, | |
150 nvim_lsp = true, | |
151 nvim_lua = true, | |
402
13fc3aebcf46
Disable spell completions
Zeger Van de Vannet <zegervdv@me.com>
parents:
401
diff
changeset
|
152 spell = false, |
388 | 153 vsnip = true, |
380 | 154 }, |
372 | 155 } |
346
d717168f424f
Switch to nvim-compe for completion
zegervdv <zegervdv@me.com>
parents:
345
diff
changeset
|
156 |
372 | 157 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] |
158 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]] | |
159 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] | |
380 | 160 end, |
372 | 161 } |
162 use { | |
163 { | |
164 'nvim-treesitter/nvim-treesitter', | |
380 | 165 config = function() |
166 require 'nvim-treesitter.highlight' | |
370
5ffb0fd7b98d
Move treesitter config into packer_compiled
zegervdv <zegervdv@me.com>
parents:
368
diff
changeset
|
167 |
406 | 168 require('nvim-treesitter.configs').setup { |
380 | 169 highlight = { enable = false }, |
372 | 170 incremental_selection = { |
171 enable = true, | |
172 keymaps = { | |
380 | 173 init_selection = 'gnn', |
174 node_incremental = 'grn', | |
175 scope_incremental = 'grc', | |
176 node_decremental = 'grm', | |
177 }, | |
372 | 178 }, |
179 refactor = { | |
180 highlight_definitions = { enable = true }, | |
380 | 181 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, |
372 | 182 navigation = { |
183 enable = true, | |
380 | 184 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, |
370
5ffb0fd7b98d
Move treesitter config into packer_compiled
zegervdv <zegervdv@me.com>
parents:
368
diff
changeset
|
185 }, |
372 | 186 }, |
187 textobjects = { | |
188 move = { | |
189 enable = true, | |
380 | 190 goto_next_start = { [']]'] = '@block.outer' }, |
191 goto_previous_start = { ['[['] = '@block.outer' }, | |
192 goto_next_end = { [']['] = '@block.outer' }, | |
193 goto_previous_end = { ['[]'] = '@block.outer' }, | |
370
5ffb0fd7b98d
Move treesitter config into packer_compiled
zegervdv <zegervdv@me.com>
parents:
368
diff
changeset
|
194 }, |
361 | 195 }, |
380 | 196 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, |
361 | 197 } |
380 | 198 end, |
372 | 199 }, |
200 'nvim-treesitter/nvim-treesitter-refactor', | |
201 'nvim-treesitter/nvim-treesitter-textobjects', | |
380 | 202 { 'nvim-treesitter/playground', opt = true }, |
372 | 203 } |
388 | 204 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } |
406 | 205 use { |
206 'glepnir/lspsaga.nvim', | |
207 config = function() | |
208 require('lspsaga').init_lsp_saga {} | |
209 end, | |
210 } | |
211 use { | |
212 'rmagatti/goto-preview', | |
213 config = function() | |
214 require('goto-preview').setup {} | |
215 end, | |
216 } | |
404
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
217 use { |
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
218 'jose-elias-alvarez/null-ls.nvim', |
406 | 219 requires = 'nvim-lua/plenary.nvim', |
404
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
220 } |
408
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
221 use { |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
222 'folke/lua-dev.nvim', |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
223 } |
361 | 224 |
372 | 225 -- Vanity |
226 use { | |
227 'yamatsum/nvim-web-nonicons', | |
228 requires = 'kyazdani42/nvim-web-devicons', | |
406 | 229 config = function() |
230 require 'nvim-nonicons' | |
231 end, | |
372 | 232 } |
361 | 233 |
372 | 234 use { |
235 'glepnir/galaxyline.nvim', | |
236 branch = 'main', | |
237 -- your statusline | |
380 | 238 config = function() |
239 local gl = require 'galaxyline' | |
372 | 240 local colors = require('galaxyline.theme').default |
406 | 241 local condition = require 'galaxyline.condition' |
372 | 242 local gls = gl.section |
243 | |
244 colors.bg = '#2C323C' | |
361 | 245 |
372 | 246 gls.left[1] = { |
247 RainbowRed = { | |
406 | 248 provider = function() |
249 return '▊ ' | |
250 end, | |
380 | 251 highlight = { colors.blue, colors.bg }, |
372 | 252 }, |
253 } | |
254 | |
255 gls.left[2] = { | |
256 FileIcon = { | |
257 provider = 'FileIcon', | |
258 condition = condition.buffer_not_empty, | |
380 | 259 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, |
372 | 260 }, |
261 } | |
361 | 262 |
372 | 263 gls.left[3] = { |
264 FileName = { | |
265 provider = 'FileName', | |
266 condition = condition.buffer_not_empty, | |
380 | 267 highlight = { colors.magenta, colors.bg, 'bold' }, |
268 }, | |
372 | 269 } |
270 | |
271 gls.right[1] = { | |
272 ShowLspClient = { | |
273 provider = 'GetLspClient', | |
380 | 274 condition = function() |
275 local tbl = { ['dashboard'] = true, [''] = true } | |
406 | 276 if tbl[vim.bo.filetype] then |
277 return false | |
278 end | |
372 | 279 return true |
280 end, | |
406 | 281 icon = require('nvim-nonicons').get 'server' .. ' LSP:', |
380 | 282 highlight = { colors.green, colors.bg, 'bold' }, |
283 }, | |
372 | 284 } |
361 | 285 |
372 | 286 gls.right[2] = { |
287 LineInfo = { | |
288 provider = 'LineColumn', | |
289 separator = ' ', | |
380 | 290 separator_highlight = { 'NONE', colors.bg }, |
291 highlight = { colors.fg, colors.bg }, | |
372 | 292 }, |
293 } | |
361 | 294 |
372 | 295 gls.right[3] = { |
296 PerCent = { | |
297 provider = 'LinePercent', | |
298 separator = ' ', | |
380 | 299 separator_highlight = { 'NONE', colors.bg }, |
300 highlight = { colors.fg, colors.bg, 'bold' }, | |
301 }, | |
372 | 302 } |
303 gls.right[8] = { | |
304 RainbowBlue = { | |
406 | 305 provider = function() |
306 return ' ▊' | |
307 end, | |
380 | 308 highlight = { colors.blue, colors.bg }, |
372 | 309 }, |
310 } | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
311 |
372 | 312 gls.short_line_left[1] = { |
313 BufferType = { | |
314 provider = 'FileTypeName', | |
315 separator = ' ', | |
380 | 316 separator_highlight = { 'NONE', colors.bg }, |
317 highlight = { colors.blue, colors.bg, 'bold' }, | |
318 }, | |
372 | 319 } |
320 | |
321 gls.short_line_left[2] = { | |
322 SFileName = { | |
380 | 323 provider = 'SFileName', |
372 | 324 condition = condition.buffer_not_empty, |
380 | 325 highlight = { colors.fg, colors.bg, 'bold' }, |
326 }, | |
372 | 327 } |
325
ce396166d009
Move packer setup in a function, load on demand
zegervdv <zegervdv@me.com>
parents:
324
diff
changeset
|
328 |
372 | 329 gls.short_line_right[1] = { |
380 | 330 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, |
372 | 331 } |
332 end, | |
333 } | |
334 | |
335 -- File navigation | |
380 | 336 use { 'justinmk/vim-dirvish' } |
338
890fe7d01f19
Use toggleterm as more robust terminal integration
zegervdv <zegervdv@me.com>
parents:
337
diff
changeset
|
337 |
372 | 338 -- Colorscheme |
339 use { | |
340 'zegervdv/one-lush', | |
341 requires = 'rktjmp/lush.nvim', | |
342 config = function() | |
381 | 343 require 'lush_theme.one-lush' |
344 vim.cmd [[ colorscheme one-lush ]] | |
372 | 345 end, |
346 } | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
347 |
372 | 348 -- Terminal |
349 use { | |
350 'akinsho/nvim-toggleterm.lua', | |
351 config = function() | |
406 | 352 require('toggleterm').setup { |
381 | 353 size = 15, |
372 | 354 open_mapping = [[<F12>]], |
381 | 355 shade_filetypes = { 'none' }, |
372 | 356 shade_terminals = true, |
357 persist_size = true, | |
358 direction = 'horizontal', | |
359 } | |
360 end, | |
361 } | |
336
7a8b66395d69
Add floating terminal to be toggled via c-z
zegervdv <zegervdv@me.com>
parents:
335
diff
changeset
|
362 |
372 | 363 -- Filetypes |
380 | 364 use { 'Glench/Vim-Jinja2-Syntax' } |
372 | 365 end) |
366 | |
367 -- LSP config | |
380 | 368 local lsp = require 'lspconfig' |
406 | 369 local null_ls = require 'null-ls' |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
370 |
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
371 local on_attach = function(client) |
372 | 372 local nnoremap = vim.keymap.nnoremap |
373 local inoremap = vim.keymap.inoremap | |
394
a80312c2755b
Add goto-preview in favour of lspsaga for previewing
Zeger Van de Vannet <zegervdv@me.com>
parents:
390
diff
changeset
|
374 -- nnoremap { '', require'lspsaga.diagnostic'.show_line_diagnostics, silent = true } |
380 | 375 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } |
376 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true } | |
406 | 377 nnoremap { 'K', require('lspsaga.hover').render_hover_doc, silent = true } |
380 | 378 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } |
379 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } | |
380 nnoremap { 'gr', vim.lsp.buf.references, silent = true } | |
381 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } | |
406 | 382 nnoremap { |
383 '<c-p>', | |
384 function() | |
385 vim.lsp.buf.formatting_sync({}, 5000) | |
386 end, | |
387 silent = true, | |
388 } | |
394
a80312c2755b
Add goto-preview in favour of lspsaga for previewing
Zeger Van de Vannet <zegervdv@me.com>
parents:
390
diff
changeset
|
389 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } |
406 | 390 nnoremap { 'gp', require('goto-preview').goto_preview_definition, silent = true } |
391 nnoremap { 'gP', require('goto-preview').close_all_win, silent = true } | |
372 | 392 |
380 | 393 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } |
382 | 394 |
406 | 395 vim.fn.sign_define( |
396 'LspDiagnosticsSignError', | |
397 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' } | |
398 ) | |
398 | 399 vim.fn.sign_define('LspDiagnosticsSignWarning', { |
400 texthl = 'LspDiagnosticsSignWarning', | |
401 linehl = '', | |
402 numhl = '', | |
403 text = '▎', | |
404 }) | |
405 vim.fn.sign_define('LspDiagnosticsSignInformation', { | |
406 texthl = 'LspDiagnosticsSignInformation', | |
407 linehl = '', | |
408 numhl = '', | |
409 text = '▎', | |
410 }) | |
406 | 411 vim.fn.sign_define( |
412 'LspDiagnosticsSignHint', | |
413 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' } | |
414 ) | |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
415 end |
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
416 |
380 | 417 vim.lsp.handlers['textDocument/formatting'] = function(err, _, result, _, bufnr) |
406 | 418 if err ~= nil or result == nil then |
419 return | |
420 end | |
380 | 421 if not vim.api.nvim_buf_get_option(bufnr, 'modified') then |
364
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
422 local view = vim.fn.winsaveview() |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
423 vim.lsp.util.apply_text_edits(result, bufnr) |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
424 -- Fix to reload Treesitter |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
425 -- vim.api.nvim_command("edit") |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
426 vim.fn.winrestview(view) |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
427 end |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
428 end |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
429 |
406 | 430 vim.lsp.handlers['textDocument/publishDiagnostics'] = function(...) |
431 vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = true, update_in_insert = false })(...) | |
432 end | |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
433 |
403
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
434 local capabilities = vim.lsp.protocol.make_client_capabilities() |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
435 capabilities.textDocument.completion.completionItem.snippetSupport = true |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
436 capabilities.textDocument.completion.completionItem.resolveSupport = { |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
437 properties = { |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
438 'documentation', |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
439 'detail', |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
440 'additionalTextEdits', |
406 | 441 }, |
403
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
442 } |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
443 |
483c3746730f
Pass capabilities for snippet completion
Zeger Van de Vannet <zegervdv@me.com>
parents:
402
diff
changeset
|
444 lsp.pyright.setup { on_attach = on_attach, capabilities = capabilities } |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
445 |
404
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
446 null_ls.setup { |
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
447 on_attach = on_attach, |
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
448 sources = { |
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
449 null_ls.builtins.formatting.black, |
405 | 450 null_ls.builtins.formatting.stylua, |
404
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
451 }, |
04483ffbd282
Replace efm with null-ls
Zeger Van de Vannet <zegervdv@me.com>
parents:
403
diff
changeset
|
452 } |
332
5b166328c2fd
Use localconfig lua file to load device specific configuration
Zeger Van de Vannet <zegervdv@me.com>
parents:
331
diff
changeset
|
453 |
408
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
454 local luadev = require('lua-dev').setup { |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
455 lspconfig = { |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
456 cmd = { 'lua-language-server' }, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
457 on_attach = on_attach, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
458 capabilities = capabilities, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
459 settings = { |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
460 Lua = { |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
461 diagnostics = { |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
462 globals = { 'use' }, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
463 }, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
464 }, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
465 }, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
466 }, |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
467 } |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
468 |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
469 lsp.sumneko_lua.setup(luadev) |
4406fc85ba0a
Add lua-language-server and lua-dev config for lua plugin development
zegervdv <zegervdv@me.com>
parents:
406
diff
changeset
|
470 |
332
5b166328c2fd
Use localconfig lua file to load device specific configuration
Zeger Van de Vannet <zegervdv@me.com>
parents:
331
diff
changeset
|
471 -- Try importing local config |
5b166328c2fd
Use localconfig lua file to load device specific configuration
Zeger Van de Vannet <zegervdv@me.com>
parents:
331
diff
changeset
|
472 local ok, localconfig = pcall(require, 'localconfig') |
406 | 473 if ok then |
474 localconfig.setup { on_attach = on_attach, capabilities = capabilities } | |
475 end |