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