Mercurial > dotfiles
annotate dot_config/nvim/config.lua @ 401:7948403a514c
Add plenary for local config scripts
author | Zeger Van de Vannet <zegervdv@me.com> |
---|---|
date | Fri, 16 Jul 2021 08:52:18 +0200 |
parents | e147fa291eb4 |
children | 13fc3aebcf46 |
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 |
380 | 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 |
380 | 78 use { 'tjdevries/astronauta.nvim', config = function() require 'astronauta.keymap' end } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
79 |
399
59db83251de2
Add vim-fetch to open file patterns with linenrs/colnrs
zegervdv <zegervdv@me.com>
parents:
398
diff
changeset
|
80 -- Opening files |
59db83251de2
Add vim-fetch to open file patterns with linenrs/colnrs
zegervdv <zegervdv@me.com>
parents:
398
diff
changeset
|
81 use { 'wsdjeg/vim-fetch' } |
59db83251de2
Add vim-fetch to open file patterns with linenrs/colnrs
zegervdv <zegervdv@me.com>
parents:
398
diff
changeset
|
82 |
372 | 83 -- Indent lines |
84 use { | |
85 'lukas-reineke/indent-blankline.nvim', | |
380 | 86 config = function() |
87 vim.g.indent_blankline_buftype_exclude = { 'terminal', 'help', 'nofile' } | |
372 | 88 vim.g.indent_blankline_show_first_indent_level = false |
89 end, | |
90 } | |
371
1dfda47d5d9e
Add more lua based plugins: lush, navigator, numb
zegervdv <zegervdv@me.com>
parents:
370
diff
changeset
|
91 |
372 | 92 -- Increment/decrement |
93 use { | |
94 'zegervdv/nrpattern.nvim', | |
95 requires = 'tpope/vim-repeat', | |
380 | 96 config = function() |
97 local nrpattern = require 'nrpattern' | |
98 local defaults = require 'nrpattern.default' | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
99 |
380 | 100 defaults[{ 'input', 'output' }] = |
101 { priority = 12, filetypes = { 'verilog', 'systemverilog' } } | |
102 defaults[{ '\'1', '\'0' }] = { priority = 9, filetypes = { 'verilog', 'systemverilog' } } | |
372 | 103 |
104 nrpattern.setup(defaults) | |
105 end, | |
106 } | |
362 | 107 |
372 | 108 -- Tmux |
109 use { | |
110 'numtostr/navigator.nvim', | |
111 config = function() | |
112 require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } | |
362 | 113 |
372 | 114 local nnoremap = vim.keymap.nnoremap |
115 nnoremap { '<c-h>', require'Navigator'.left, silent = true } | |
116 nnoremap { '<c-j>', require'Navigator'.down, silent = true } | |
117 nnoremap { '<c-k>', require'Navigator'.up, silent = true } | |
118 nnoremap { '<c-l>', require'Navigator'.right, silent = true } | |
119 end, | |
380 | 120 requires = 'tjdevries/astronauta.nvim', |
390
bfaff08e7e54
Run navigator cfg after astronauta is loaded
Zeger Van de Vannet <zegervdv@me.com>
parents:
389
diff
changeset
|
121 after = 'astronauta.nvim', |
372 | 122 } |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
123 |
372 | 124 -- Completion/snippets/LSP |
380 | 125 use { 'neovim/nvim-lspconfig' } |
372 | 126 use { |
127 'hrsh7th/nvim-compe', | |
380 | 128 config = function() |
372 | 129 require'compe'.setup { |
380 | 130 enabled = true, |
131 autocomplete = true, | |
132 debug = false, | |
133 min_length = 1, | |
134 preselect = 'enable', | |
135 throttle_time = 80, | |
136 source_timeout = 1000, | |
137 incomplete_delay = 400, | |
138 max_abbr_width = 100, | |
139 max_kind_width = 100, | |
140 max_menu_width = 100, | |
141 documentation = true, | |
346
d717168f424f
Switch to nvim-compe for completion
zegervdv <zegervdv@me.com>
parents:
345
diff
changeset
|
142 |
372 | 143 source = { |
380 | 144 path = true, |
145 buffer = true, | |
146 nvim_lsp = true, | |
147 nvim_lua = true, | |
148 spell = true, | |
388 | 149 vsnip = true, |
380 | 150 }, |
372 | 151 } |
346
d717168f424f
Switch to nvim-compe for completion
zegervdv <zegervdv@me.com>
parents:
345
diff
changeset
|
152 |
372 | 153 vim.cmd [[ inoremap <silent><expr> <C-y> compe#complete() ]] |
154 vim.cmd [[ inoremap <silent><expr> <CR> compe#confirm({ 'keys': "\<Plug>delimitMateCR", 'mode': '' }) ]] | |
155 vim.cmd [[ inoremap <silent><expr> <C-e> compe#close('<C-e>') ]] | |
380 | 156 end, |
372 | 157 } |
158 use { | |
159 { | |
160 'nvim-treesitter/nvim-treesitter', | |
380 | 161 config = function() |
162 require 'nvim-treesitter.highlight' | |
370
5ffb0fd7b98d
Move treesitter config into packer_compiled
zegervdv <zegervdv@me.com>
parents:
368
diff
changeset
|
163 |
372 | 164 require'nvim-treesitter.configs'.setup { |
380 | 165 highlight = { enable = false }, |
372 | 166 incremental_selection = { |
167 enable = true, | |
168 keymaps = { | |
380 | 169 init_selection = 'gnn', |
170 node_incremental = 'grn', | |
171 scope_incremental = 'grc', | |
172 node_decremental = 'grm', | |
173 }, | |
372 | 174 }, |
175 refactor = { | |
176 highlight_definitions = { enable = true }, | |
380 | 177 smart_rename = { enable = true, keymaps = { smart_rename = 'gsr' } }, |
372 | 178 navigation = { |
179 enable = true, | |
380 | 180 keymaps = { goto_definition = 'gnd', list_definitions = 'gnD' }, |
370
5ffb0fd7b98d
Move treesitter config into packer_compiled
zegervdv <zegervdv@me.com>
parents:
368
diff
changeset
|
181 }, |
372 | 182 }, |
183 textobjects = { | |
184 move = { | |
185 enable = true, | |
380 | 186 goto_next_start = { [']]'] = '@block.outer' }, |
187 goto_previous_start = { ['[['] = '@block.outer' }, | |
188 goto_next_end = { [']['] = '@block.outer' }, | |
189 goto_previous_end = { ['[]'] = '@block.outer' }, | |
370
5ffb0fd7b98d
Move treesitter config into packer_compiled
zegervdv <zegervdv@me.com>
parents:
368
diff
changeset
|
190 }, |
361 | 191 }, |
380 | 192 playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false }, |
361 | 193 } |
380 | 194 end, |
372 | 195 }, |
196 'nvim-treesitter/nvim-treesitter-refactor', | |
197 'nvim-treesitter/nvim-treesitter-textobjects', | |
380 | 198 { 'nvim-treesitter/playground', opt = true }, |
372 | 199 } |
388 | 200 use { 'hrsh7th/vim-vsnip', requires = 'hrsh7th/vim-vsnip-integ' } |
380 | 201 use { 'glepnir/lspsaga.nvim', config = function() require'lspsaga'.init_lsp_saga {} end } |
394
a80312c2755b
Add goto-preview in favour of lspsaga for previewing
Zeger Van de Vannet <zegervdv@me.com>
parents:
390
diff
changeset
|
202 use { 'rmagatti/goto-preview', config = function() require'goto-preview'.setup {} end } |
361 | 203 |
372 | 204 -- Vanity |
205 use { | |
206 'yamatsum/nvim-web-nonicons', | |
207 requires = 'kyazdani42/nvim-web-devicons', | |
380 | 208 config = function() require 'nvim-nonicons' end, |
372 | 209 } |
361 | 210 |
372 | 211 use { |
212 'glepnir/galaxyline.nvim', | |
213 branch = 'main', | |
214 -- your statusline | |
380 | 215 config = function() |
216 local gl = require 'galaxyline' | |
372 | 217 local colors = require('galaxyline.theme').default |
218 local condition = require('galaxyline.condition') | |
219 local gls = gl.section | |
220 | |
221 colors.bg = '#2C323C' | |
361 | 222 |
372 | 223 gls.left[1] = { |
224 RainbowRed = { | |
225 provider = function() return '▊ ' end, | |
380 | 226 highlight = { colors.blue, colors.bg }, |
372 | 227 }, |
228 } | |
229 | |
230 gls.left[2] = { | |
231 FileIcon = { | |
232 provider = 'FileIcon', | |
233 condition = condition.buffer_not_empty, | |
380 | 234 highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg }, |
372 | 235 }, |
236 } | |
361 | 237 |
372 | 238 gls.left[3] = { |
239 FileName = { | |
240 provider = 'FileName', | |
241 condition = condition.buffer_not_empty, | |
380 | 242 highlight = { colors.magenta, colors.bg, 'bold' }, |
243 }, | |
372 | 244 } |
245 | |
246 gls.right[1] = { | |
247 ShowLspClient = { | |
248 provider = 'GetLspClient', | |
380 | 249 condition = function() |
250 local tbl = { ['dashboard'] = true, [''] = true } | |
251 if tbl[vim.bo.filetype] then return false end | |
372 | 252 return true |
253 end, | |
254 icon = require'nvim-nonicons'.get('server') .. ' LSP:', | |
380 | 255 highlight = { colors.green, colors.bg, 'bold' }, |
256 }, | |
372 | 257 } |
361 | 258 |
372 | 259 gls.right[2] = { |
260 LineInfo = { | |
261 provider = 'LineColumn', | |
262 separator = ' ', | |
380 | 263 separator_highlight = { 'NONE', colors.bg }, |
264 highlight = { colors.fg, colors.bg }, | |
372 | 265 }, |
266 } | |
361 | 267 |
372 | 268 gls.right[3] = { |
269 PerCent = { | |
270 provider = 'LinePercent', | |
271 separator = ' ', | |
380 | 272 separator_highlight = { 'NONE', colors.bg }, |
273 highlight = { colors.fg, colors.bg, 'bold' }, | |
274 }, | |
372 | 275 } |
276 gls.right[8] = { | |
277 RainbowBlue = { | |
278 provider = function() return ' ▊' end, | |
380 | 279 highlight = { colors.blue, colors.bg }, |
372 | 280 }, |
281 } | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
282 |
372 | 283 gls.short_line_left[1] = { |
284 BufferType = { | |
285 provider = 'FileTypeName', | |
286 separator = ' ', | |
380 | 287 separator_highlight = { 'NONE', colors.bg }, |
288 highlight = { colors.blue, colors.bg, 'bold' }, | |
289 }, | |
372 | 290 } |
291 | |
292 gls.short_line_left[2] = { | |
293 SFileName = { | |
380 | 294 provider = 'SFileName', |
372 | 295 condition = condition.buffer_not_empty, |
380 | 296 highlight = { colors.fg, colors.bg, 'bold' }, |
297 }, | |
372 | 298 } |
325
ce396166d009
Move packer setup in a function, load on demand
zegervdv <zegervdv@me.com>
parents:
324
diff
changeset
|
299 |
372 | 300 gls.short_line_right[1] = { |
380 | 301 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, |
372 | 302 } |
303 end, | |
304 } | |
305 | |
306 -- File navigation | |
380 | 307 use { 'justinmk/vim-dirvish' } |
338
890fe7d01f19
Use toggleterm as more robust terminal integration
zegervdv <zegervdv@me.com>
parents:
337
diff
changeset
|
308 |
372 | 309 -- Colorscheme |
310 use { | |
311 'zegervdv/one-lush', | |
312 requires = 'rktjmp/lush.nvim', | |
313 config = function() | |
381 | 314 require 'lush_theme.one-lush' |
315 vim.cmd [[ colorscheme one-lush ]] | |
372 | 316 end, |
317 } | |
324
64a0c6cec54c
Use packer for plugin management in lua
zegervdv <zegervdv@me.com>
parents:
323
diff
changeset
|
318 |
372 | 319 -- Terminal |
320 use { | |
321 'akinsho/nvim-toggleterm.lua', | |
322 config = function() | |
323 require'toggleterm'.setup { | |
381 | 324 size = 15, |
372 | 325 open_mapping = [[<F12>]], |
381 | 326 shade_filetypes = { 'none' }, |
372 | 327 shade_terminals = true, |
328 persist_size = true, | |
329 direction = 'horizontal', | |
330 } | |
331 end, | |
332 } | |
336
7a8b66395d69
Add floating terminal to be toggled via c-z
zegervdv <zegervdv@me.com>
parents:
335
diff
changeset
|
333 |
372 | 334 -- Filetypes |
380 | 335 use { 'Glench/Vim-Jinja2-Syntax' } |
372 | 336 |
337 end) | |
338 | |
339 -- LSP config | |
380 | 340 local lsp = require 'lspconfig' |
341 local lsputil = require 'lspconfig.util' | |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
342 |
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
343 local on_attach = function(client) |
372 | 344 local nnoremap = vim.keymap.nnoremap |
345 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
|
346 -- nnoremap { '', require'lspsaga.diagnostic'.show_line_diagnostics, silent = true } |
380 | 347 nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } |
348 nnoremap { '<c-]>', vim.lsp.buf.definition, silent = true } | |
349 nnoremap { 'K', require'lspsaga.hover'.render_hover_doc, silent = true } | |
350 nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } | |
351 nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } | |
352 nnoremap { 'gr', vim.lsp.buf.references, silent = true } | |
353 nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } | |
388 | 354 nnoremap { '<c-p>', function() vim.lsp.buf.formatting_sync({}, 5000) end, silent = true } |
394
a80312c2755b
Add goto-preview in favour of lspsaga for previewing
Zeger Van de Vannet <zegervdv@me.com>
parents:
390
diff
changeset
|
355 -- nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } |
a80312c2755b
Add goto-preview in favour of lspsaga for previewing
Zeger Van de Vannet <zegervdv@me.com>
parents:
390
diff
changeset
|
356 nnoremap { 'gp', require'goto-preview'.goto_preview_definition, silent = true } |
a80312c2755b
Add goto-preview in favour of lspsaga for previewing
Zeger Van de Vannet <zegervdv@me.com>
parents:
390
diff
changeset
|
357 nnoremap { 'gP', require'goto-preview'.close_all_win, silent = true } |
372 | 358 |
380 | 359 inoremap { '<c-l>', vim.lsp.buf.signature_help, silent = true } |
382 | 360 |
398 | 361 vim.fn.sign_define('LspDiagnosticsSignError', |
362 { texthl = 'LspDiagnosticsSignError', linehl = '', numhl = '', text = '▎' }) | |
363 vim.fn.sign_define('LspDiagnosticsSignWarning', { | |
364 texthl = 'LspDiagnosticsSignWarning', | |
365 linehl = '', | |
366 numhl = '', | |
367 text = '▎', | |
368 }) | |
369 vim.fn.sign_define('LspDiagnosticsSignInformation', { | |
370 texthl = 'LspDiagnosticsSignInformation', | |
371 linehl = '', | |
372 numhl = '', | |
373 text = '▎', | |
374 }) | |
375 vim.fn.sign_define('LspDiagnosticsSignHint', | |
376 { texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = '', text = '▎' }) | |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
377 end |
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
378 |
380 | 379 vim.lsp.handlers['textDocument/formatting'] = function(err, _, result, _, bufnr) |
380 if err ~= nil or result == nil then return end | |
381 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
|
382 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
|
383 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
|
384 -- 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
|
385 -- 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
|
386 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
|
387 end |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
388 end |
f300ef1bc475
Do not run LSP diagnostics while in insert mode
Zeger Van de Vannet <zegervdv@me.com>
parents:
363
diff
changeset
|
389 |
380 | 390 vim.lsp.handlers['textDocument/publishDiagnostics'] = |
391 function(...) | |
392 vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, | |
393 { underline = true, update_in_insert = false })(...) | |
394 end | |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
395 |
380 | 396 lsp.pyright.setup { on_attach = on_attach } |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
397 |
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
398 if (vim.fn.executable('efm-langserver') == 1) then |
323
3b25f3aa7014
Use efm folders to store efm configuration per language
zegervdv <zegervdv@me.com>
parents:
322
diff
changeset
|
399 require 'efm/python' |
379 | 400 require 'efm/lua' |
322
deb606f02fc4
Test if flake8, black are available before adding
zegervdv <zegervdv@me.com>
parents:
321
diff
changeset
|
401 |
323
3b25f3aa7014
Use efm folders to store efm configuration per language
zegervdv <zegervdv@me.com>
parents:
322
diff
changeset
|
402 -- May not be installed, use pcall to handle errors |
368
72e8dd5a4ab5
Clean up LSP peek functions
Zeger Van de Vannet <zegervdv@me.com>
parents:
367
diff
changeset
|
403 -- pcall(require, 'efm/systemverilog') |
327 | 404 pcall(require, 'efm/flp') |
323
3b25f3aa7014
Use efm folders to store efm configuration per language
zegervdv <zegervdv@me.com>
parents:
322
diff
changeset
|
405 |
380 | 406 local language_cfg = require 'efm/languages' |
322
deb606f02fc4
Test if flake8, black are available before adding
zegervdv <zegervdv@me.com>
parents:
321
diff
changeset
|
407 |
367
f0a89299e854
Enable EFM only on selected filetypes
zegervdv <zegervdv@me.com>
parents:
366
diff
changeset
|
408 local filetypes = {} |
380 | 409 for lang, _ in pairs(language_cfg) do table.insert(filetypes, lang) end |
367
f0a89299e854
Enable EFM only on selected filetypes
zegervdv <zegervdv@me.com>
parents:
366
diff
changeset
|
410 |
380 | 411 lsp.efm.setup { |
367
f0a89299e854
Enable EFM only on selected filetypes
zegervdv <zegervdv@me.com>
parents:
366
diff
changeset
|
412 on_attach = on_attach, |
f0a89299e854
Enable EFM only on selected filetypes
zegervdv <zegervdv@me.com>
parents:
366
diff
changeset
|
413 filetypes = filetypes, |
380 | 414 init_options = { documentFormatting = true }, |
367
f0a89299e854
Enable EFM only on selected filetypes
zegervdv <zegervdv@me.com>
parents:
366
diff
changeset
|
415 root_dir = lsputil.root_pattern('.git', '.hg'), |
380 | 416 settings = { rootMarkers = { '.git/', '.hg/' }, languages = language_cfg }, |
319
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
417 } |
b93f12d23fbd
Rename init.lua to config.lua
Zeger Van de Vannet <zegervdv@me.com>
parents:
diff
changeset
|
418 end |
332
5b166328c2fd
Use localconfig lua file to load device specific configuration
Zeger Van de Vannet <zegervdv@me.com>
parents:
331
diff
changeset
|
419 |
5b166328c2fd
Use localconfig lua file to load device specific configuration
Zeger Van de Vannet <zegervdv@me.com>
parents:
331
diff
changeset
|
420 -- 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
|
421 local ok, localconfig = pcall(require, 'localconfig') |
380 | 422 if ok then localconfig.setup { on_attach = on_attach } end |