@@ -207,7 +207,7 @@ vim.api.nvim_create_autocmd('TextYankPost', {
207207-- [[ Install `lazy.nvim` plugin manager ]]
208208-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
209209local lazypath = vim .fn .stdpath ' data' .. ' /lazy/lazy.nvim'
210- if not vim .uv .fs_stat (lazypath ) then
210+ if not ( vim .uv or vim . loop ) .fs_stat (lazypath ) then
211211 local lazyrepo = ' https://github.com/folke/lazy.nvim.git'
212212 local out = vim .fn .system { ' git' , ' clone' , ' --filter=blob:none' , ' --branch=stable' , lazyrepo , lazypath }
213213 if vim .v .shell_error ~= 0 then
@@ -274,20 +274,55 @@ require('lazy').setup({
274274 { -- Useful plugin to show you pending keybinds.
275275 ' folke/which-key.nvim' ,
276276 event = ' VimEnter' , -- Sets the loading event to 'VimEnter'
277- config = function () -- This is the function that runs, AFTER loading
278- require (' which-key' ).setup ()
277+ opts = {
278+ icons = {
279+ -- set icon mappings to true if you have a Nerd Font
280+ mappings = vim .g .have_nerd_font ,
281+ -- If you are using a Nerd Font: set icons.keys to an empty table which will use the
282+ -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
283+ keys = vim .g .have_nerd_font and {} or {
284+ Up = ' <Up> ' ,
285+ Down = ' <Down> ' ,
286+ Left = ' <Left> ' ,
287+ Right = ' <Right> ' ,
288+ C = ' <C-…> ' ,
289+ M = ' <M-…> ' ,
290+ D = ' <D-…> ' ,
291+ S = ' <S-…> ' ,
292+ CR = ' <CR> ' ,
293+ Esc = ' <Esc> ' ,
294+ ScrollWheelDown = ' <ScrollWheelDown> ' ,
295+ ScrollWheelUp = ' <ScrollWheelUp> ' ,
296+ NL = ' <NL> ' ,
297+ BS = ' <BS> ' ,
298+ Space = ' <Space> ' ,
299+ Tab = ' <Tab> ' ,
300+ F1 = ' <F1>' ,
301+ F2 = ' <F2>' ,
302+ F3 = ' <F3>' ,
303+ F4 = ' <F4>' ,
304+ F5 = ' <F5>' ,
305+ F6 = ' <F6>' ,
306+ F7 = ' <F7>' ,
307+ F8 = ' <F8>' ,
308+ F9 = ' <F9>' ,
309+ F10 = ' <F10>' ,
310+ F11 = ' <F11>' ,
311+ F12 = ' <F12>' ,
312+ },
313+ },
279314
280315 -- Document existing key chains
281- require ( ' which-key ' ). add {
282- { ' <leader>c' , group = ' [C]ode' },
316+ spec = {
317+ { ' <leader>c' , group = ' [C]ode' , mode = { ' n ' , ' x ' } },
283318 { ' <leader>d' , group = ' [D]ocument' },
284319 { ' <leader>r' , group = ' [R]ename' },
285320 { ' <leader>s' , group = ' [S]earch' },
286321 { ' <leader>w' , group = ' [W]orkspace' },
287322 { ' <leader>t' , group = ' [T]oggle' },
288323 { ' <leader>h' , group = ' Git [H]unk' , mode = { ' n' , ' v' } },
289- }
290- end ,
324+ },
325+ } ,
291326 },
292327
293328 -- NOTE: Plugins can specify dependencies.
@@ -470,8 +505,9 @@ require('lazy').setup({
470505 --
471506 -- In this case, we create a function that lets us more easily define mappings specific
472507 -- for LSP related items. It sets the mode, buffer and description for us each time.
473- local map = function (keys , func , desc )
474- vim .keymap .set (' n' , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
508+ local map = function (keys , func , desc , mode )
509+ mode = mode or ' n'
510+ vim .keymap .set (mode , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
475511 end
476512
477513 -- Jump to the definition of the word under your cursor.
@@ -505,7 +541,7 @@ require('lazy').setup({
505541
506542 -- Execute a code action, usually your cursor needs to be on top of an error
507543 -- or a suggestion from your LSP for this to activate.
508- map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' )
544+ map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' , { ' n ' , ' x ' } )
509545
510546 -- WARN: This is not Goto Definition, this is Goto Declaration.
511547 -- For example, in C this would take you to the header.
@@ -637,7 +673,7 @@ require('lazy').setup({
637673 {
638674 ' <leader>f' ,
639675 function ()
640- require (' conform' ).format { async = true , lsp_fallback = true }
676+ require (' conform' ).format { async = true , lsp_format = ' fallback ' }
641677 end ,
642678 mode = ' ' ,
643679 desc = ' [F]ormat buffer' ,
@@ -650,9 +686,15 @@ require('lazy').setup({
650686 -- have a well standardized coding style. You can add additional
651687 -- languages here or re-enable it for the disabled ones.
652688 local disable_filetypes = { c = true , cpp = true }
689+ local lsp_format_opt
690+ if disable_filetypes [vim .bo [bufnr ].filetype ] then
691+ lsp_format_opt = ' never'
692+ else
693+ lsp_format_opt = ' fallback'
694+ end
653695 return {
654696 timeout_ms = 500 ,
655- lsp_fallback = not disable_filetypes [ vim . bo [ bufnr ]. filetype ] ,
697+ lsp_format = lsp_format_opt ,
656698 }
657699 end ,
658700 formatters_by_ft = {
@@ -843,6 +885,8 @@ require('lazy').setup({
843885 { -- Highlight, edit, and navigate code
844886 ' nvim-treesitter/nvim-treesitter' ,
845887 build = ' :TSUpdate' ,
888+ main = ' nvim-treesitter.configs' , -- Sets main module to use for opts
889+ -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
846890 opts = {
847891 ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' , ' c_sharp' , ' java' },
848892 auto_install = true ,
@@ -855,19 +899,12 @@ require('lazy').setup({
855899 },
856900 indent = { enable = true , disable = { ' ruby' } },
857901 },
858- config = function (_ , opts )
859- -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
860-
861- --- @diagnostic disable-next-line : missing-fields
862- require (' nvim-treesitter.configs' ).setup (opts )
863-
864- -- There are additional nvim-treesitter modules that you can use to interact
865- -- with nvim-treesitter. You should go explore a few and see what interests you:
866- --
867- -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
868- -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
869- -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
870- end ,
902+ -- There are additional nvim-treesitter modules that you can use to interact
903+ -- with nvim-treesitter. You should go explore a few and see what interests you:
904+ --
905+ -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
906+ -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
907+ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
871908 },
872909
873910 -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
0 commit comments