@@ -119,7 +119,7 @@ vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)
119119-- Enable break indent
120120vim .o .breakindent = true
121121
122- -- Save undo history
122+ -- Enable undo/redo changes even after closing and reopening a file
123123vim .o .undofile = true
124124
125125-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
@@ -177,11 +177,11 @@ vim.diagnostic.config {
177177 update_in_insert = false ,
178178 severity_sort = true ,
179179 float = { border = ' rounded' , source = ' if_many' },
180- underline = { severity = vim .diagnostic .severity .ERROR },
180+ underline = { severity = { min = vim .diagnostic .severity .WARN } },
181181
182182 -- Can switch between these as you prefer
183183 virtual_text = true , -- Text shows up at the end of the line
184- virtual_lines = false , -- Teest shows up underneath the line, with virtual lines
184+ virtual_lines = false , -- Text shows up underneath the line, with virtual lines
185185
186186 -- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
187187 jump = { float = true },
@@ -275,13 +275,16 @@ require('lazy').setup({
275275 -- See `:help gitsigns` to understand what the configuration keys do
276276 { -- Adds git related signs to the gutter, as well as utilities for managing changes
277277 ' lewis6991/gitsigns.nvim' ,
278+ --- @module ' gitsigns'
279+ --- @type Gitsigns.Config
280+ --- @diagnostic disable-next-line : missing-fields
278281 opts = {
279282 signs = {
280- add = { text = ' +' },
281- change = { text = ' ~' },
282- delete = { text = ' _' },
283- topdelete = { text = ' ‾' },
284- changedelete = { text = ' ~' },
283+ add = { text = ' +' }, --- @diagnostic disable-line : missing-fields
284+ change = { text = ' ~' }, --- @diagnostic disable-line : missing-fields
285+ delete = { text = ' _' }, --- @diagnostic disable-line : missing-fields
286+ topdelete = { text = ' ‾' }, --- @diagnostic disable-line : missing-fields
287+ changedelete = { text = ' ~' }, --- @diagnostic disable-line : missing-fields
285288 },
286289 },
287290 },
@@ -303,6 +306,9 @@ require('lazy').setup({
303306 { -- Useful plugin to show you pending keybinds.
304307 ' folke/which-key.nvim' ,
305308 event = ' VimEnter' ,
309+ --- @module ' which-key'
310+ --- @type wk.Opts
311+ --- @diagnostic disable-next-line : missing-fields
306312 opts = {
307313 -- delay between pressing a key and opening which-key (milliseconds)
308314 delay = 0 ,
@@ -312,7 +318,8 @@ require('lazy').setup({
312318 spec = {
313319 { ' <leader>s' , group = ' [S]earch' , mode = { ' n' , ' v' } },
314320 { ' <leader>t' , group = ' [T]oggle' },
315- { ' <leader>h' , group = ' Git [H]unk' , mode = { ' n' , ' v' } },
321+ { ' <leader>h' , group = ' Git [H]unk' , mode = { ' n' , ' v' } }, -- Enable gitsigns recommended keymaps first
322+ { ' gr' , group = ' LSP Actions' , mode = { ' n' } },
316323 },
317324 },
318325 },
@@ -480,14 +487,19 @@ require('lazy').setup({
480487 -- Automatically install LSPs and related tools to stdpath for Neovim
481488 -- Mason must be loaded before its dependents so we need to set it up here.
482489 -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
483- { ' mason-org/mason.nvim' , opts = {} },
490+ {
491+ ' mason-org/mason.nvim' ,
492+ --- @module ' mason.settings'
493+ --- @type MasonSettings
494+ --- @diagnostic disable-next-line : missing-fields
495+ opts = {},
496+ },
497+ -- Maps LSP server names between nvim-lspconfig and Mason package names.
498+ ' mason-org/mason-lspconfig.nvim' ,
484499 ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
485500
486501 -- Useful status updates for LSP.
487502 { ' j-hui/fidget.nvim' , opts = {} },
488-
489- -- Allows extra capabilities provided by blink.cmp
490- ' saghen/blink.cmp' ,
491503 },
492504 config = function ()
493505 -- Brief aside: **What is LSP?**
@@ -583,15 +595,10 @@ require('lazy').setup({
583595 end ,
584596 })
585597
586- -- LSP servers and clients are able to communicate to each other what features they support.
587- -- By default, Neovim doesn't support everything that is in the LSP specification.
588- -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
589- -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
590- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
591-
592598 -- Enable the following language servers
593599 -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
594600 -- See `:help lsp-config` for information about keys and how to configure
601+ --- @type table<string , vim.lsp.Config>
595602 local servers = {
596603 -- clangd = {},
597604 -- gopls = {},
@@ -603,6 +610,37 @@ require('lazy').setup({
603610 --
604611 -- But for many setups, the LSP (`ts_ls`) will work just fine
605612 -- ts_ls = {},
613+
614+ stylua = {}, -- Used to format Lua code
615+
616+ -- Special Lua Config, as recommended by neovim help docs
617+ lua_ls = {
618+ on_init = function (client )
619+ if client .workspace_folders then
620+ local path = client .workspace_folders [1 ].name
621+ if path ~= vim .fn .stdpath ' config' and (vim .uv .fs_stat (path .. ' /.luarc.json' ) or vim .uv .fs_stat (path .. ' /.luarc.jsonc' )) then return end
622+ end
623+
624+ client .config .settings .Lua = vim .tbl_deep_extend (' force' , client .config .settings .Lua , {
625+ runtime = {
626+ version = ' LuaJIT' ,
627+ path = { ' lua/?.lua' , ' lua/?/init.lua' },
628+ },
629+ workspace = {
630+ checkThirdParty = false ,
631+ -- NOTE: this is a lot slower and will cause issues when working on your own configuration.
632+ -- See https://github.com/neovim/nvim-lspconfig/issues/3189
633+ library = vim .tbl_extend (' force' , vim .api .nvim_get_runtime_file (' ' , true ), {
634+ ' ${3rd}/luv/library' ,
635+ ' ${3rd}/busted/library' ,
636+ }),
637+ },
638+ })
639+ end ,
640+ settings = {
641+ Lua = {},
642+ },
643+ },
606644 }
607645
608646 -- Ensure the servers and tools above are installed
@@ -614,45 +652,15 @@ require('lazy').setup({
614652 -- You can press `g?` for help in this menu.
615653 local ensure_installed = vim .tbl_keys (servers or {})
616654 vim .list_extend (ensure_installed , {
617- ' lua_ls' , -- Lua Language server
618- ' stylua' , -- Used to format Lua code
619655 -- You can add other tools here that you want Mason to install
620656 })
621657
622658 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
623659
624660 for name , server in pairs (servers ) do
625- server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
626661 vim .lsp .config (name , server )
627662 vim .lsp .enable (name )
628663 end
629-
630- -- Special Lua Config, as recommended by neovim help docs
631- vim .lsp .config (' lua_ls' , {
632- on_init = function (client )
633- if client .workspace_folders then
634- local path = client .workspace_folders [1 ].name
635- if path ~= vim .fn .stdpath ' config' and (vim .uv .fs_stat (path .. ' /.luarc.json' ) or vim .uv .fs_stat (path .. ' /.luarc.jsonc' )) then return end
636- end
637-
638- client .config .settings .Lua = vim .tbl_deep_extend (' force' , client .config .settings .Lua , {
639- runtime = {
640- version = ' LuaJIT' ,
641- path = { ' lua/?.lua' , ' lua/?/init.lua' },
642- },
643- workspace = {
644- checkThirdParty = false ,
645- -- NOTE: this is a lot slower and will cause issues when working on your own configuration.
646- -- See https://github.com/neovim/nvim-lspconfig/issues/3189
647- library = vim .api .nvim_get_runtime_file (' ' , true ),
648- },
649- })
650- end ,
651- settings = {
652- Lua = {},
653- },
654- })
655- vim .lsp .enable ' lua_ls'
656664 end ,
657665 },
658666
@@ -668,6 +676,8 @@ require('lazy').setup({
668676 desc = ' [F]ormat buffer' ,
669677 },
670678 },
679+ --- @module ' conform'
680+ --- @type conform.setupOpts
671681 opts = {
672682 notify_on_error = false ,
673683 format_on_save = function (bufnr )
@@ -725,8 +735,8 @@ require('lazy').setup({
725735 opts = {},
726736 },
727737 },
728- --- @module ' blink.cmp'
729- --- @type blink.cmp.Config
738+ --- @module ' blink.cmp'
739+ --- @type blink.cmp.Config
730740 opts = {
731741 keymap = {
732742 -- 'default' (recommended) for mappings similar to built-in completions
@@ -811,7 +821,15 @@ require('lazy').setup({
811821 },
812822
813823 -- Highlight todo, notes, etc in comments
814- { ' folke/todo-comments.nvim' , event = ' VimEnter' , dependencies = { ' nvim-lua/plenary.nvim' }, opts = { signs = false } },
824+ {
825+ ' folke/todo-comments.nvim' ,
826+ event = ' VimEnter' ,
827+ dependencies = { ' nvim-lua/plenary.nvim' },
828+ --- @module ' todo-comments'
829+ --- @type TodoOptions
830+ --- @diagnostic disable-next-line : missing-fields
831+ opts = { signs = false },
832+ },
815833
816834 { -- Collection of various small independent plugins/modules
817835 ' nvim-mini/mini.nvim' ,
@@ -851,12 +869,33 @@ require('lazy').setup({
851869
852870 { -- Highlight, edit, and navigate code
853871 ' nvim-treesitter/nvim-treesitter' ,
872+ lazy = false ,
873+ build = ' :TSUpdate' ,
874+ branch = ' main' ,
875+ -- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
854876 config = function ()
855- local filetypes = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' }
856- require (' nvim-treesitter' ).install (filetypes )
877+ local parsers = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' }
878+ require (' nvim-treesitter' ).install (parsers )
857879 vim .api .nvim_create_autocmd (' FileType' , {
858- pattern = filetypes ,
859- callback = function () vim .treesitter .start () end ,
880+ callback = function (args )
881+ local buf , filetype = args .buf , args .match
882+
883+ local language = vim .treesitter .language .get_lang (filetype )
884+ if not language then return end
885+
886+ -- check if parser exists and load it
887+ if not vim .treesitter .language .add (language ) then return end
888+ -- enables syntax highlighting and other treesitter features
889+ vim .treesitter .start (buf , language )
890+
891+ -- enables treesitter based folds
892+ -- for more info on folds see `:help folds`
893+ -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
894+ -- vim.wo.foldmethod = 'expr'
895+
896+ -- enables treesitter based indentation
897+ vim .bo .indentexpr = " v:lua.require'nvim-treesitter'.indentexpr()"
898+ end ,
860899 })
861900 end ,
862901 },
@@ -875,7 +914,7 @@ require('lazy').setup({
875914 -- require 'kickstart.plugins.lint',
876915 -- require 'kickstart.plugins.autopairs',
877916 -- require 'kickstart.plugins.neo-tree',
878- -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
917+ -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommended keymaps
879918
880919 -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
881920 -- This is the easiest way to modularize your config.
@@ -887,7 +926,7 @@ require('lazy').setup({
887926 -- Or use telescope!
888927 -- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
889928 -- you can continue same window with `<space>sr` which resumes last telescope search
890- }, {
929+ }, { --- @diagnostic disable-line : missing-fields
891930 ui = {
892931 -- If you are using a Nerd Font: set icons to an empty table which will use the
893932 -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
0 commit comments