@@ -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.
@@ -428,6 +463,9 @@ require('lazy').setup({
428463 -- Useful status updates for LSP.
429464 -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
430465 { ' j-hui/fidget.nvim' , opts = {} },
466+
467+ -- Allows extra capabilities provided by nvim-cmp
468+ ' hrsh7th/cmp-nvim-lsp' ,
431469 },
432470 config = function ()
433471 -- Brief aside: **What is LSP?**
@@ -467,8 +505,9 @@ require('lazy').setup({
467505 --
468506 -- In this case, we create a function that lets us more easily define mappings specific
469507 -- for LSP related items. It sets the mode, buffer and description for us each time.
470- local map = function (keys , func , desc )
471- 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 })
472511 end
473512
474513 -- Jump to the definition of the word under your cursor.
@@ -502,7 +541,7 @@ require('lazy').setup({
502541
503542 -- Execute a code action, usually your cursor needs to be on top of an error
504543 -- or a suggestion from your LSP for this to activate.
505- 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 ' } )
506545
507546 -- WARN: This is not Goto Definition, this is Goto Declaration.
508547 -- For example, in C this would take you to the header.
@@ -549,6 +588,15 @@ require('lazy').setup({
549588 end ,
550589 })
551590
591+ -- Change diagnostic symbols in the sign column (gutter)
592+ -- if vim.g.have_nerd_font then
593+ -- local signs = { Error = '', Warn = '', Hint = '', Info = '' }
594+ -- for type, icon in pairs(signs) do
595+ -- local hl = 'DiagnosticSign' .. type
596+ -- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
597+ -- end
598+ -- end
599+
552600 -- LSP servers and clients are able to communicate to each other what features they support.
553601 -- By default, Neovim doesn't support everything that is in the LSP specification.
554602 -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
@@ -575,8 +623,8 @@ require('lazy').setup({
575623 -- Some languages (like typescript) have entire language plugins that can be useful:
576624 -- https://github.com/pmizio/typescript-tools.nvim
577625 --
578- -- But for many setups, the LSP (`tsserver `) will work just fine
579- -- tsserver = {},
626+ -- But for many setups, the LSP (`ts_ls `) will work just fine
627+ -- ts_ls = {},
580628 --
581629
582630 lua_ls = {
@@ -617,7 +665,7 @@ require('lazy').setup({
617665 local server = servers [server_name ] or {}
618666 -- This handles overriding only values explicitly passed
619667 -- by the server configuration above. Useful when disabling
620- -- certain features of an LSP (for example, turning off formatting for tsserver )
668+ -- certain features of an LSP (for example, turning off formatting for ts_ls )
621669 server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
622670 require (' lspconfig' )[server_name ].setup (server )
623671 end ,
@@ -634,7 +682,7 @@ require('lazy').setup({
634682 {
635683 ' <leader>f' ,
636684 function ()
637- require (' conform' ).format { async = true , lsp_fallback = true }
685+ require (' conform' ).format { async = true , lsp_format = ' fallback ' }
638686 end ,
639687 mode = ' ' ,
640688 desc = ' [F]ormat buffer' ,
@@ -647,9 +695,15 @@ require('lazy').setup({
647695 -- have a well standardized coding style. You can add additional
648696 -- languages here or re-enable it for the disabled ones.
649697 local disable_filetypes = { c = true , cpp = true }
698+ local lsp_format_opt
699+ if disable_filetypes [vim .bo [bufnr ].filetype ] then
700+ lsp_format_opt = ' never'
701+ else
702+ lsp_format_opt = ' fallback'
703+ end
650704 return {
651705 timeout_ms = 500 ,
652- lsp_fallback = not disable_filetypes [ vim . bo [ bufnr ]. filetype ] ,
706+ lsp_format = lsp_format_opt ,
653707 }
654708 end ,
655709 formatters_by_ft = {
@@ -840,6 +894,8 @@ require('lazy').setup({
840894 { -- Highlight, edit, and navigate code
841895 ' nvim-treesitter/nvim-treesitter' ,
842896 build = ' :TSUpdate' ,
897+ main = ' nvim-treesitter.configs' , -- Sets main module to use for opts
898+ -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
843899 opts = {
844900 ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' },
845901 -- Autoinstall languages that are not installed
@@ -853,22 +909,15 @@ require('lazy').setup({
853909 },
854910 indent = { enable = true , disable = { ' ruby' } },
855911 },
856- config = function (_ , opts )
857- -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
858-
859- --- @diagnostic disable-next-line : missing-fields
860- require (' nvim-treesitter.configs' ).setup (opts )
861-
862- -- There are additional nvim-treesitter modules that you can use to interact
863- -- with nvim-treesitter. You should go explore a few and see what interests you:
864- --
865- -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
866- -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
867- -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
868- end ,
912+ -- There are additional nvim-treesitter modules that you can use to interact
913+ -- with nvim-treesitter. You should go explore a few and see what interests you:
914+ --
915+ -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
916+ -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
917+ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
869918 },
870919
871- -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
920+ -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
872921 -- init.lua. If you want these files, they are in the repository, so you can just download them and
873922 -- place them in the correct locations.
874923
@@ -888,8 +937,12 @@ require('lazy').setup({
888937 -- This is the easiest way to modularize your config.
889938 --
890939 -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
891- -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
892940 -- { import = 'custom.plugins' },
941+ --
942+ -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
943+ -- Or use telescope!
944+ -- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
945+ -- you can continue same window with `<space>sr` which resumes last telescope search
893946}, {
894947 ui = {
895948 -- If you are using a Nerd Font: set icons to an empty table which will use the
0 commit comments