@@ -141,7 +141,6 @@ vim.opt.signcolumn = 'yes'
141141vim .opt .updatetime = 250
142142
143143-- Decrease mapped sequence wait time
144- -- Displays which-key popup sooner
145144vim .opt .timeoutlen = 300
146145
147146-- Configure how new splits should be opened
@@ -213,7 +212,7 @@ vim.api.nvim_create_autocmd('TextYankPost', {
213212-- [[ Install `lazy.nvim` plugin manager ]]
214213-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
215214local lazypath = vim .fn .stdpath ' data' .. ' /lazy/lazy.nvim'
216- if not vim .uv .fs_stat (lazypath ) then
215+ if not ( vim .uv or vim . loop ) .fs_stat (lazypath ) then
217216 local lazyrepo = ' https://github.com/folke/lazy.nvim.git'
218217 local out = vim .fn .system { ' git' , ' clone' , ' --filter=blob:none' , ' --branch=stable' , lazyrepo , lazypath }
219218 if vim .v .shell_error ~= 0 then
@@ -273,27 +272,64 @@ require('lazy').setup({
273272 -- which loads which-key before all the UI elements are loaded. Events can be
274273 -- normal autocommands events (`:help autocmd-events`).
275274 --
276- -- Then, because we use the `config` key, the configuration only runs
277- -- after the plugin has been loaded:
278- -- config = function() ... end
275+ -- Then, because we use the `opts` key (recommended), the configuration runs
276+ -- after the plugin has been loaded as `require(MODULE).setup(opts)`.
279277
280278 { -- Useful plugin to show you pending keybinds.
281279 ' folke/which-key.nvim' ,
282280 event = ' VimEnter' , -- Sets the loading event to 'VimEnter'
283- config = function () -- This is the function that runs, AFTER loading
284- require (' which-key' ).setup ()
281+ opts = {
282+ -- delay between pressing a key and opening which-key (milliseconds)
283+ -- this setting is independent of vim.opt.timeoutlen
284+ delay = 0 ,
285+ icons = {
286+ -- set icon mappings to true if you have a Nerd Font
287+ mappings = vim .g .have_nerd_font ,
288+ -- If you are using a Nerd Font: set icons.keys to an empty table which will use the
289+ -- default which-key.nvim defined Nerd Font icons, otherwise define a string table
290+ keys = vim .g .have_nerd_font and {} or {
291+ Up = ' <Up> ' ,
292+ Down = ' <Down> ' ,
293+ Left = ' <Left> ' ,
294+ Right = ' <Right> ' ,
295+ C = ' <C-…> ' ,
296+ M = ' <M-…> ' ,
297+ D = ' <D-…> ' ,
298+ S = ' <S-…> ' ,
299+ CR = ' <CR> ' ,
300+ Esc = ' <Esc> ' ,
301+ ScrollWheelDown = ' <ScrollWheelDown> ' ,
302+ ScrollWheelUp = ' <ScrollWheelUp> ' ,
303+ NL = ' <NL> ' ,
304+ BS = ' <BS> ' ,
305+ Space = ' <Space> ' ,
306+ Tab = ' <Tab> ' ,
307+ F1 = ' <F1>' ,
308+ F2 = ' <F2>' ,
309+ F3 = ' <F3>' ,
310+ F4 = ' <F4>' ,
311+ F5 = ' <F5>' ,
312+ F6 = ' <F6>' ,
313+ F7 = ' <F7>' ,
314+ F8 = ' <F8>' ,
315+ F9 = ' <F9>' ,
316+ F10 = ' <F10>' ,
317+ F11 = ' <F11>' ,
318+ F12 = ' <F12>' ,
319+ },
320+ },
285321
286322 -- Document existing key chains
287- require ( ' which-key ' ). add {
288- { ' <leader>c' , group = ' [C]ode' },
323+ spec = {
324+ { ' <leader>c' , group = ' [C]ode' , mode = { ' n ' , ' x ' } },
289325 { ' <leader>d' , group = ' [D]ocument' },
290326 { ' <leader>r' , group = ' [R]ename' },
291327 { ' <leader>s' , group = ' [S]earch' },
292328 { ' <leader>w' , group = ' [W]orkspace' },
293329 { ' <leader>t' , group = ' [T]oggle' },
294330 { ' <leader>h' , group = ' Git [H]unk' , mode = { ' n' , ' v' } },
295- }
296- end ,
331+ },
332+ } ,
297333 },
298334
299335 -- NOTE: Plugins can specify dependencies.
@@ -427,7 +463,9 @@ require('lazy').setup({
427463 ' neovim/nvim-lspconfig' ,
428464 dependencies = {
429465 -- Automatically install LSPs and related tools to stdpath for Neovim
430- { ' williamboman/mason.nvim' , config = true }, -- NOTE: Must be loaded before dependants
466+ -- Mason must be loaded before its dependents so we need to set it up here.
467+ -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
468+ { ' williamboman/mason.nvim' , opts = {} },
431469 ' williamboman/mason-lspconfig.nvim' ,
432470 ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
433471
@@ -476,8 +514,9 @@ require('lazy').setup({
476514 --
477515 -- In this case, we create a function that lets us more easily define mappings specific
478516 -- for LSP related items. It sets the mode, buffer and description for us each time.
479- local map = function (keys , func , desc )
480- vim .keymap .set (' n' , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
517+ local map = function (keys , func , desc , mode )
518+ mode = mode or ' n'
519+ vim .keymap .set (mode , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
481520 end
482521
483522 -- Jump to the definition of the word under your cursor.
@@ -511,7 +550,7 @@ require('lazy').setup({
511550
512551 -- Execute a code action, usually your cursor needs to be on top of an error
513552 -- or a suggestion from your LSP for this to activate.
514- map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' )
553+ map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' , { ' n ' , ' x ' } )
515554
516555 -- WARN: This is not Goto Definition, this is Goto Declaration.
517556 -- For example, in C this would take you to the header.
@@ -558,6 +597,16 @@ require('lazy').setup({
558597 end ,
559598 })
560599
600+ -- Change diagnostic symbols in the sign column (gutter)
601+ -- if vim.g.have_nerd_font then
602+ -- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
603+ -- local diagnostic_signs = {}
604+ -- for type, icon in pairs(signs) do
605+ -- diagnostic_signs[vim.diagnostic.severity[type]] = icon
606+ -- end
607+ -- vim.diagnostic.config { signs = { text = diagnostic_signs } }
608+ -- end
609+
561610 -- LSP servers and clients are able to communicate to each other what features they support.
562611 -- By default, Neovim doesn't support everything that is in the LSP specification.
563612 -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
@@ -586,13 +635,13 @@ require('lazy').setup({
586635 -- Some languages (like typescript) have entire language plugins that can be useful:
587636 -- https://github.com/pmizio/typescript-tools.nvim
588637 --
589- -- But for many setups, the LSP (`tsserver `) will work just fine
590- -- tsserver = {},
638+ -- But for many setups, the LSP (`ts_ls `) will work just fine
639+ -- ts_ls = {},
591640 --
592641
593642 lua_ls = {
594- -- cmd = {...},
595- -- filetypes = { ...},
643+ -- cmd = { ... },
644+ -- filetypes = { ... },
596645 -- capabilities = {},
597646 settings = {
598647 Lua = {
@@ -607,13 +656,16 @@ require('lazy').setup({
607656 }
608657
609658 -- Ensure the servers and tools above are installed
610- -- To check the current status of installed tools and/or manually install
611- -- other tools, you can run
659+ --
660+ -- To check the current status of installed tools and/or manually install
661+ -- other tools, you can run
612662 -- :Mason
613663 --
614- -- You can press `g?` for help in this menu.
615- require (' mason' ).setup ()
616-
664+ -- You can press `g?` for help in this menu.
665+ --
666+ -- `mason` had to be setup earlier: to configure its options see the
667+ -- `dependencies` table for `nvim-lspconfig` above.
668+ --
617669 -- You can add other tools here that you want Mason to install
618670 -- for you, so that they are available from within Neovim.
619671 local ensure_installed = vim .tbl_keys (servers or {})
@@ -628,7 +680,7 @@ require('lazy').setup({
628680 local server = servers [server_name ] or {}
629681 -- This handles overriding only values explicitly passed
630682 -- by the server configuration above. Useful when disabling
631- -- certain features of an LSP (for example, turning off formatting for tsserver )
683+ -- certain features of an LSP (for example, turning off formatting for ts_ls )
632684 server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
633685 require (' lspconfig' )[server_name ].setup (server )
634686 end ,
@@ -645,7 +697,7 @@ require('lazy').setup({
645697 {
646698 ' <leader>f' ,
647699 function ()
648- require (' conform' ).format { async = true , lsp_fallback = true }
700+ require (' conform' ).format { async = true , lsp_format = ' fallback ' }
649701 end ,
650702 mode = ' ' ,
651703 desc = ' [F]ormat buffer' ,
@@ -658,9 +710,15 @@ require('lazy').setup({
658710 -- have a well standardized coding style. You can add additional
659711 -- languages here or re-enable it for the disabled ones.
660712 local disable_filetypes = { c = true , cpp = true }
713+ local lsp_format_opt
714+ if disable_filetypes [vim .bo [bufnr ].filetype ] then
715+ lsp_format_opt = ' never'
716+ else
717+ lsp_format_opt = ' fallback'
718+ end
661719 return {
662720 timeout_ms = 500 ,
663- lsp_fallback = not disable_filetypes [ vim . bo [ bufnr ]. filetype ] ,
721+ lsp_format = lsp_format_opt ,
664722 }
665723 end ,
666724 formatters_by_ft = {
@@ -852,6 +910,8 @@ require('lazy').setup({
852910 { -- Highlight, edit, and navigate code
853911 ' nvim-treesitter/nvim-treesitter' ,
854912 build = ' :TSUpdate' ,
913+ main = ' nvim-treesitter.configs' , -- Sets main module to use for opts
914+ -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
855915 opts = {
856916 ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' },
857917 -- Autoinstall languages that are not installed
@@ -865,22 +925,15 @@ require('lazy').setup({
865925 },
866926 indent = { enable = true , disable = { ' ruby' } },
867927 },
868- config = function (_ , opts )
869- -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
870-
871- --- @diagnostic disable-next-line : missing-fields
872- require (' nvim-treesitter.configs' ).setup (opts )
873-
874- -- There are additional nvim-treesitter modules that you can use to interact
875- -- with nvim-treesitter. You should go explore a few and see what interests you:
876- --
877- -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
878- -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
879- -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
880- end ,
928+ -- There are additional nvim-treesitter modules that you can use to interact
929+ -- with nvim-treesitter. You should go explore a few and see what interests you:
930+ --
931+ -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
932+ -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
933+ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
881934 },
882935
883- -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
936+ -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
884937 -- init.lua. If you want these files, they are in the repository, so you can just download them and
885938 -- place them in the correct locations.
886939
@@ -900,8 +953,12 @@ require('lazy').setup({
900953 -- This is the easiest way to modularize your config.
901954 --
902955 -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
903- -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
904956 { import = ' custom.plugins' },
957+ --
958+ -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
959+ -- Or use telescope!
960+ -- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
961+ -- you can continue same window with `<space>sr` which resumes last telescope search
905962}, {
906963 ui = {
907964 -- If you are using a Nerd Font: set icons to an empty table which will use the
0 commit comments