@@ -163,49 +163,33 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
163
163
vim .keymap .set (' n' , ' <leader>fs' , ' <cmd>:w<CR>' , { desc = ' [F]ile [S]ave' })
164
164
vim .keymap .set (' n' , ' <leader>qq' , ' <cmd>:q<CR>' , { desc = ' [Q]uit [Q]uit' })
165
165
166
- local is_google3 = function (fname )
167
- local citc_results = vim .fs .find (' .citc' , { upward = true , path = fname })
168
- if # citc_results ~= 0 then
169
- return vim .fs .dirname (citc_results [1 ])
170
- else
171
- return nil
172
- end
166
+ -- The .nvim.local.lua may set this variable to provide an LSP at higher priority than
167
+ -- what we configure here.
168
+ SUPPRESS_LSP = function (_ )
169
+ -- Parameter is the buffer's file name as string
170
+ return false
173
171
end
174
172
175
- local ciderlsp = ' ciderlsp'
176
-
177
- -- TODO: Shove google-specific config elsewhere.
178
- vim .lsp .config (' ciderlsp' , {
179
- cmd = { ' /google/bin/releases/cider/ciderlsp/ciderlsp' , ' --tooltag=nvim-lsp' , ' --noforward_sync_responses' },
180
- -- root_markers = { '.citc' },
181
- root_dir = function (bufnr , on_dir )
182
- local citc_dir = is_google3 (vim .api .nvim_buf_get_name (bufnr ))
183
- if citc_dir then
184
- on_dir (citc_dir )
185
- end
186
- end ,
187
- name = ciderlsp ,
188
- })
189
-
190
- vim .lsp .enable ' ciderlsp'
191
-
192
- -- clangd is set up differently than all of the other LSPs due to
193
- -- https://github.com/mason-org/mason.nvim/issues/1578?
194
- vim .lsp .config (' clangd' , {
195
- cmd = { ' clangd' , ' --background-index' },
196
- root_markers = { ' .clangd' , ' compile_commands.json' },
197
- root_dir = function (bufnr , on_dir )
173
+ local get_lsp_root_dir_fn = function (root_markers )
174
+ return function (bufnr , on_dir )
198
175
local fname = vim .api .nvim_buf_get_name (bufnr )
199
- if is_google3 (fname ) then
176
+ if SUPPRESS_LSP (fname ) then
200
177
return
201
178
end
202
- local root_markers = { ' .clangd ' , ' compile_commands.json ' }
179
+
203
180
local root_dirs = vim .fs .find (root_markers , { upward = true , path = fname })
204
181
if # root_dirs == 0 then
205
182
on_dir (vim .fs .dirname (fname ))
206
183
end
207
184
on_dir (vim .fs .dirname (root_dirs [1 ]))
208
- end ,
185
+ end
186
+ end
187
+
188
+ -- clangd is set up differently than all of the other LSPs due to
189
+ -- https://github.com/mason-org/mason.nvim/issues/1578?
190
+ vim .lsp .config (' clangd' , {
191
+ cmd = { ' clangd' , ' --background-index' },
192
+ root_dir = get_lsp_root_dir_fn { ' .clangd' , ' compile_commands.json' },
209
193
filetypes = { ' c' , ' cpp' , ' cc' },
210
194
})
211
195
vim .lsp .enable ' clangd'
@@ -267,8 +251,8 @@ rtp:prepend(lazypath)
267
251
--
268
252
-- To update plugins you can run
269
253
-- :Lazy update
270
- require ( ' lazy ' ). setup ({
271
- -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
254
+
255
+ PACKAGES = {
272
256
' NMAC427/guess-indent.nvim' , -- Detect tabstop and shiftwidth automatically
273
257
274
258
{
@@ -729,14 +713,6 @@ require('lazy').setup({
729
713
vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
730
714
end , ' [T]oggle Inlay [H]ints' )
731
715
end
732
-
733
- -- TODO: Google-specific!
734
- if client .name == ciderlsp then
735
- print ' Trying to override to CS'
736
- vim .keymap .set (' n' , ' <leader>*' , function ()
737
- vim .cmd ' Telescope codesearch find_query'
738
- end , { buffer = event .buf , desc = ' code search' })
739
- end
740
716
end ,
741
717
})
742
718
@@ -1030,23 +1006,6 @@ require('lazy').setup({
1030
1006
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
1031
1007
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
1032
1008
},
1033
- {
1034
- -- TODO: Google-specific
1035
- -- https://g3doc.corp.google.com/experimental/users/vintharas/telescope-codesearch.nvim/README.md
1036
- ' vintharas/telescope-codesearch.nvim' ,
1037
- dependencies = { ' nvim-telescope/telescope.nvim' },
1038
- url = ' sso://user/vintharas/telescope-codesearch.nvim' ,
1039
- keys = {
1040
- {
1041
- ' <leader>sc' ,
1042
- ' <cmd>Telescope codesearch find_query<cr>' ,
1043
- desc = ' [S]earch [C]oogle via CodeSearch' ,
1044
- },
1045
- },
1046
- config = function ()
1047
- require (' telescope' ).load_extension ' codesearch'
1048
- end ,
1049
- },
1050
1009
1051
1010
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
1052
1011
-- init.lua. If you want these files, they are in the repository, so you can just download them and
@@ -1074,7 +1033,16 @@ require('lazy').setup({
1074
1033
-- Or use telescope!
1075
1034
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
1076
1035
-- you can continue same window with `<space>sr` which resumes last telescope search
1077
- }, {
1036
+ }
1037
+
1038
+ -- Load local init file, if it exists
1039
+ -- NOTE: We do this before lazy setup so that the local init file can append anything it needs to PACKAGES
1040
+ local local_init_file = vim .fn .expand ' ~/.nvim.local.lua'
1041
+ if vim .uv .fs_stat (local_init_file ) then
1042
+ loadfile (local_init_file )()
1043
+ end
1044
+
1045
+ require (' lazy' ).setup (PACKAGES , {
1078
1046
ui = {
1079
1047
-- If you are using a Nerd Font: set icons to an empty table which will use the
1080
1048
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
@@ -1095,10 +1063,3 @@ require('lazy').setup({
1095
1063
},
1096
1064
},
1097
1065
})
1098
-
1099
- -- Load local init file, if it exists
1100
- local local_init_file = vim .fn .expand ' ~/.nvim.local.lua'
1101
- if vim .uv .fs_stat (local_init_file ) then
1102
- print ' Loading local init file!'
1103
- loadfile (local_init_file )()
1104
- end
0 commit comments