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