@@ -163,49 +163,33 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
163163vim .keymap .set (' n' , ' <leader>fs' , ' <cmd>:w<CR>' , { desc = ' [F]ile [S]ave' })
164164vim .keymap .set (' n' , ' <leader>qq' , ' <cmd>:q<CR>' , { desc = ' [Q]uit [Q]uit' })
165165
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
173171end
174172
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 )
198175 local fname = vim .api .nvim_buf_get_name (bufnr )
199- if is_google3 (fname ) then
176+ if SUPPRESS_LSP (fname ) then
200177 return
201178 end
202- local root_markers = { ' .clangd ' , ' compile_commands.json ' }
179+
203180 local root_dirs = vim .fs .find (root_markers , { upward = true , path = fname })
204181 if # root_dirs == 0 then
205182 on_dir (vim .fs .dirname (fname ))
206183 end
207184 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' },
209193 filetypes = { ' c' , ' cpp' , ' cc' },
210194})
211195vim .lsp .enable ' clangd'
@@ -267,8 +251,8 @@ rtp:prepend(lazypath)
267251--
268252-- To update plugins you can run
269253-- :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 = {
272256 ' NMAC427/guess-indent.nvim' , -- Detect tabstop and shiftwidth automatically
273257
274258 {
@@ -729,14 +713,6 @@ require('lazy').setup({
729713 vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
730714 end , ' [T]oggle Inlay [H]ints' )
731715 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
740716 end ,
741717 })
742718
@@ -1030,23 +1006,6 @@ require('lazy').setup({
10301006 -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
10311007 -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
10321008 },
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- },
10501009
10511010 -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
10521011 -- 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({
10741033 -- Or use telescope!
10751034 -- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
10761035 -- 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 , {
10781046 ui = {
10791047 -- If you are using a Nerd Font: set icons to an empty table which will use the
10801048 -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
@@ -1095,10 +1063,3 @@ require('lazy').setup({
10951063 },
10961064 },
10971065})
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