@@ -36,53 +36,74 @@ return {
36
36
vim .keymap .set (mode , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
37
37
end
38
38
39
- -- Jump to the definition of the word under your cursor.
40
- -- This is where a variable was first declared, or where a function is defined, etc.
41
- -- To jump back, press <C-t>.
42
- map (' gd' , require (' telescope.builtin' ).lsp_definitions , ' [G]oto [D]efinition' )
43
- map (' <leader>cgd' , require (' telescope.builtin' ).lsp_definitions , ' [C]ode [G]oto [D]efinition' )
39
+ -- Rename the variable under your cursor.
40
+ -- Most Language Servers support renaming across files, etc.
41
+ map (' grn' , vim .lsp .buf .rename , ' [R]e[n]ame' )
42
+ map (' <leader>cn' , vim .lsp .buf .rename , ' [C]ode Re[n]ame' )
43
+
44
+ -- Execute a code action, usually your cursor needs to be on top of an error
45
+ -- or a suggestion from your LSP for this to activate.
46
+ map (' gra' , vim .lsp .buf .code_action , ' [G]oto Code [A]ction' , { ' n' , ' x' })
47
+ map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' , { ' n' , ' x' })
44
48
45
49
-- Find references for the word under your cursor.
46
- map (' gr ' , require (' telescope.builtin' ).lsp_references , ' [G]oto [R]eferences' )
50
+ map (' grr ' , require (' telescope.builtin' ).lsp_references , ' [G]oto [R]eferences' )
47
51
map (' <leader>cgr' , require (' telescope.builtin' ).lsp_references , ' [C]ode [G]oto [R]eferences' )
48
52
49
53
-- Jump to the implementation of the word under your cursor.
50
54
-- Useful when your language has ways of declaring types without an actual implementation.
51
- map (' gI ' , require (' telescope.builtin' ).lsp_implementations , ' [G]oto [I]mplementation' )
55
+ map (' gri ' , require (' telescope.builtin' ).lsp_implementations , ' [G]oto [I]mplementation' )
52
56
map (' <leader>cgI' , require (' telescope.builtin' ).lsp_implementations , ' [C]ode [G]oto [I]mplementation' )
53
57
58
+ -- Jump to the definition of the word under your cursor.
59
+ -- This is where a variable was first declared, or where a function is defined, etc.
60
+ -- To jump back, press <C-t>.
61
+ map (' grd' , require (' telescope.builtin' ).lsp_definitions , ' [G]oto [D]efinition' )
62
+ map (' <leader>cgd' , require (' telescope.builtin' ).lsp_definitions , ' [C]ode [G]oto [D]efinition' )
63
+
54
64
-- This is not Goto Definition, this is Goto Declaration.
55
65
-- For example, in C this would take you to the header.
56
- map (' gD ' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
66
+ map (' grD ' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
57
67
map (' <leader>cgD' , vim .lsp .buf .declaration , ' [C]ode [G]oto [D]eclaration' )
58
68
59
- -- Jump to the type of the word under your cursor.
60
- -- Useful when you're not sure what type a variable is and you want to see
61
- -- the definition of its *type*, not where it was *defined*.
62
- map (' <leader>cgt' , require (' telescope.builtin' ).lsp_type_definitions , ' [C]ode [G]oto [T]ype Definition' )
63
-
64
69
-- Fuzzy find all the symbols in your current document.
65
70
-- Symbols are things like variables, functions, types, etc.
71
+ map (' gO' , require (' telescope.builtin' ).lsp_document_symbols , ' Open Document Symbols' )
66
72
map (' <leader>cds' , require (' telescope.builtin' ).lsp_document_symbols , ' [C]ode [D]ocument [S]ymbols' )
67
73
68
74
-- Fuzzy find all the symbols in your current workspace.
69
75
-- Similar to document symbols, except searches over your entire project.
76
+ map (' gW' , require (' telescope.builtin' ).lsp_dynamic_workspace_symbols , ' Open Workspace Symbols' )
70
77
map (' <leader>cws' , require (' telescope.builtin' ).lsp_dynamic_workspace_symbols , ' [C]ode [W]orkspace [S]ymbols' )
71
78
72
- -- Rename the variable under your cursor.
73
- -- Most Language Servers support renaming across files, etc.
74
- map (' <leader>cn' , vim .lsp .buf .rename , ' [C]ode Re[n]ame' )
79
+ -- Jump to the type of the word under your cursor.
80
+ -- Useful when you're not sure what type a variable is and you want to see
81
+ -- the definition of its *type*, not where it was *defined*.
82
+ map (' grt' , require (' telescope.builtin' ).lsp_type_definitions , ' [G]oto [T]ype Definition' )
83
+ map (' <leader>cgt' , require (' telescope.builtin' ).lsp_type_definitions , ' [C]ode [G]oto [T]ype Definition' )
75
84
76
- -- Execute a code action, usually your cursor needs to be on top of an error
77
- -- or a suggestion from your LSP for this to activate.
78
- map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' , { ' n' , ' x' })
85
+ -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
86
+ --- @param client vim.lsp.Client
87
+ --- @param method vim.lsp.protocol.Method
88
+ --- @param bufnr ? integer some lsp support methods only in specific files
89
+ --- @return boolean
90
+ local function client_supports_method (client , method , bufnr )
91
+ if vim .fn .has ' nvim-0.11' == 1 then
92
+ return client :supports_method (method , bufnr )
93
+ else
94
+ return client .supports_method (method , { bufnr = bufnr })
95
+ end
96
+ end
79
97
80
98
-- The following two autocommands are used to highlight references of the
81
99
-- word under your cursor when your cursor rests there for a little while.
82
100
-- See `:help CursorHold` for information about when this is executed
101
+ --
83
102
-- When you move your cursor, the highlights will be cleared (the second autocommand).
84
103
local client = vim .lsp .get_client_by_id (event .data .client_id )
85
- if client and client :supports_method (vim .lsp .protocol .Methods .textDocument_documentHighlight , event .buf ) then
104
+ if
105
+ client and client_supports_method (client , vim .lsp .protocol .Methods .textDocument_documentHighlight , event .buf )
106
+ then
86
107
local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
87
108
vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
88
109
buffer = event .buf ,
@@ -106,7 +127,7 @@ return {
106
127
end
107
128
108
129
-- keymap for inlay hint toggle if supported by LSP
109
- if client and client : supports_method ( vim .lsp .protocol .Methods .textDocument_inlayHint , event .buf ) then
130
+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_inlayHint , event .buf ) then
110
131
map (' <leader>ch' , function ()
111
132
vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
112
133
end , ' [C]ode Toggle Inlay [H]ints' )
@@ -145,7 +166,7 @@ return {
145
166
-- },
146
167
},
147
168
-- gopls = {},
148
- basedpyright = { enabled = false },
169
+ basedpyright = { enabled = true },
149
170
rust_analyzer = {
150
171
-- prevent auto-config of rust_analyzer which interferes with rustaceanvim
151
172
skip_autoconfigure = true ,
0 commit comments