@@ -34,6 +34,9 @@ vim.g.maplocalleader = ' '
34
34
35
35
-- Set to true if you have a Nerd Font installed and selected in the terminal
36
36
vim .g .have_nerd_font = true
37
+ vim .g .markdown_fenced_languages = {
38
+ ' ts=typescript' ,
39
+ }
37
40
38
41
-- [[ Setting options ]]
39
42
-- See `:help vim.opt`
@@ -100,6 +103,9 @@ vim.opt.scrolloff = 10
100
103
-- See `:help 'confirm'`
101
104
vim .opt .confirm = true
102
105
106
+ -- vimrc loading in project dirs
107
+ vim .opt .exrc = true
108
+
103
109
-- [[ Basic Keymaps ]]
104
110
-- See `:help vim.keymap.set()`
105
111
@@ -162,7 +168,12 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
162
168
if vim .v .shell_error ~= 0 then
163
169
error (' Error cloning lazy.nvim:\n ' .. out )
164
170
end
165
- end --- @diagnostic disable-next-line : undefined-field
171
+ end
172
+
173
+ ---
174
+ --- @type vim.Option
175
+ local rtp = vim .opt .rtp
176
+ rtp :prepend (lazypath )
166
177
vim .opt .rtp :prepend (lazypath )
167
178
168
179
-- [[ Configure and install plugins ]]
@@ -178,7 +189,7 @@ vim.opt.rtp:prepend(lazypath)
178
189
-- NOTE: Here is where you install your plugins.
179
190
require (' lazy' ).setup ({
180
191
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
181
- ' tpope/vim-sleuth ' , -- Detect tabstop and shiftwidth automatically
192
+ ' NMAC427/guess-indent.nvim ' , -- Detect tabstop and shiftwidth automatically
182
193
183
194
-- NOTE: Plugins can also be added by using a table,
184
195
-- with the first argument being the link and the following
@@ -409,12 +420,13 @@ require('lazy').setup({
409
420
{
410
421
-- Main LSP Configuration
411
422
' neovim/nvim-lspconfig' ,
423
+ event = ' VeryLazy' ,
412
424
dependencies = {
413
425
-- Automatically install LSPs and related tools to stdpath for Neovim
414
426
-- Mason must be loaded before its dependents so we need to set it up here.
415
427
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
416
- { ' williamboman /mason.nvim' , opts = {} },
417
- ' williamboman /mason-lspconfig.nvim' ,
428
+ { ' mason-org /mason.nvim' , opts = {} },
429
+ ' mason-org /mason-lspconfig.nvim' ,
418
430
' WhoIsSethDaniel/mason-tool-installer.nvim' ,
419
431
420
432
-- Useful status updates for LSP.
@@ -424,13 +436,6 @@ require('lazy').setup({
424
436
' saghen/blink.cmp' ,
425
437
},
426
438
config = function ()
427
- -- Brief aside: **What is LSP?**
428
- --
429
- -- LSP is an initialism you've probably heard, but might not understand what it is.
430
- --
431
- -- LSP stands for Language Server Protocol. It's a protocol that helps editors
432
- -- and language tooling communicate in a standardized fashion.
433
- --
434
439
-- In general, you have a "server" which is some tool built to understand a particular
435
440
-- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
436
441
-- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
@@ -509,11 +514,7 @@ require('lazy').setup({
509
514
--- @param bufnr ? integer some lsp support methods only in specific files
510
515
--- @return boolean
511
516
local function client_supports_method (client , method , bufnr )
512
- if vim .fn .has ' nvim-0.11' == 1 then
513
- return client :supports_method (method , bufnr )
514
- else
515
- return client .supports_method (method , { bufnr = bufnr })
516
- end
517
+ return client :supports_method (method , bufnr )
517
518
end
518
519
519
520
-- The following two autocommands are used to highlight references of the
@@ -586,62 +587,72 @@ require('lazy').setup({
586
587
},
587
588
}
588
589
589
- -- LSP servers and clients are able to communicate to each other what features they support.
590
+ -- LSPs and clients are able to communicate to each other what features they support.
590
591
-- By default, Neovim doesn't support everything that is in the LSP specification.
591
592
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
592
593
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
593
- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
594
-
595
- -- Enable the following language servers
596
- -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
597
594
--
598
- -- Add any additional override configuration in the following tables. Available keys are:
599
- -- - cmd (table): Override the default command used to start the server
600
- -- - filetypes (table): Override the default list of associated filetypes for the server
601
- -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
602
- -- - settings (table): Override the default settings passed when initializing the server.
603
- -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
595
+ -- Language servers can broadly be installed in the following ways:
596
+ -- 1) via the mason package manager; or
597
+ -- 2) via your system's package manager; or
598
+ -- 3) via a release binary from a language server's repo that's accessible somewhere on your system.
599
+
600
+ -- The servers table comprises of the following sub-tables:
601
+ -- 1. mason
602
+ -- 2. others
603
+ -- Both these tables have an identical structure of language server names as keys and
604
+ -- a table of language server configuration as values.
605
+ --- @class LspServersConfig
606
+ --- @field mason table<string , vim.lsp.Config>
607
+ --- @field others table<string , vim.lsp.Config>
604
608
local servers = {
605
- clangd = {},
606
- -- gopls = {},
607
- pyright = {},
608
- -- rust_analyzer = {},
609
- ts_ls = {},
610
- -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
611
- --
612
- -- Some languages (like typescript) have entire language plugins that can be useful:
613
- -- https://github.com/pmizio/typescript-tools.nvim
614
- --
615
- -- But for many setups, the LSP (`ts_ls`) will work just fine
616
-
617
- lua_ls = {
618
- -- cmd = { ... },
619
- -- filetypes = { ... },
620
- -- capabilities = {},
621
- settings = {
622
- Lua = {
623
- completion = {
624
- callSnippet = ' Replace ' ,
625
- },
626
- -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
627
- diagnostics = {
628
- globals = {
629
- ' vim ' ,
630
- ' love ' ,
631
- },
632
- },
633
- -- diagnostics = { disable = { 'missing-fields' } },
634
- workspace = {
635
- library = {
636
- [ vim . fn . expand ' $VIMRUNTIME/lua ' ] = true ,
637
- [ vim . fn . expand ' $VIMRUNTIME/lua/vim/lsp ' ] = true ,
638
- [ ' ${3rd}/love2d/library ' ] = true , -- Add Love2D library
609
+ mason = {
610
+ -- Add any additional override configuration in any of the following tables. Available keys are:
611
+ -- - cmd (table): Override the default command used to start the server
612
+ -- - filetypes (table): Override the default list of associated filetypes for the server
613
+ -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
614
+ -- - settings (table): Override the default settings passed when initializing the server.
615
+ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
616
+ --
617
+ -- Feel free to add/remove any LSPs here that you want to install via Mason. They will automatically be installed and setup.
618
+ clangd = {},
619
+ -- gopls = {},
620
+ pyright = {},
621
+ rust_analyzer = {},
622
+ -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
623
+
624
+ -- Some languages (like typescript) have entire language plugins that can be useful:
625
+ -- https://github.com/pmizio/typescript-tools.nvim
626
+ -- But for many setups, the LSP (`ts_ls`) will work just fine
627
+ ts_ls = {
628
+ workspace_required = true ,
629
+ root_markers = { ' package.json ' },
630
+ },
631
+ denols = {
632
+ workspace_required = true ,
633
+ root_markers = { ' deno.json ' , ' deno.jsonc ' } ,
634
+ } ,
635
+ lua_ls = {
636
+ -- cmd = { ... },
637
+ -- filetypes = { ... },
638
+ -- capabilities = {},
639
+ settings = {
640
+ Lua = {
641
+ completion = {
642
+ callSnippet = ' Replace ' ,
639
643
},
644
+ -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
645
+ -- diagnostics = { disable = { 'missing-fields' } },
640
646
},
641
647
},
642
648
},
649
+ intelephense = {},
650
+ },
651
+ -- This table contains config for all language servers that are *not* installed via Mason.
652
+ -- Structure is identical to the mason table from above.
653
+ others = {
654
+ -- dartls
643
655
},
644
- intelephense = {},
645
656
}
646
657
647
658
-- Ensure the servers and tools above are installed
@@ -657,26 +668,28 @@ require('lazy').setup({
657
668
--
658
669
-- You can add other tools here that you want Mason to install
659
670
-- for you, so that they are available from within Neovim.
660
- local ensure_installed = vim .tbl_keys (servers or {})
671
+ local ensure_installed = vim .tbl_keys (servers . mason or {})
661
672
vim .list_extend (ensure_installed , {
662
673
' stylua' , -- Used to format Lua code
663
674
})
664
675
require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
676
+ -- Either merge all additional server configs from the `servers.mason` and `servers.others` tables
677
+ -- to the default language server configs as provided by nvim-lspconfig or
678
+ -- define a custom server config that's unavailable on nvim-lspconfig.
679
+
680
+ for server , config in pairs (vim .tbl_extend (' keep' , servers .mason , servers .others )) do
681
+ if not vim .tbl_isempty (config ) then
682
+ vim .lsp .config (server , config )
683
+ end
684
+ end
665
685
666
686
require (' mason-lspconfig' ).setup {
667
- ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
668
- automatic_installation = false ,
669
- handlers = {
670
- function (server_name )
671
- local server = servers [server_name ] or {}
672
- -- This handles overriding only values explicitly passed
673
- -- by the server configuration above. Useful when disabling
674
- -- certain features of an LSP (for example, turning off formatting for ts_ls)
675
- server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
676
- require (' lspconfig' )[server_name ].setup (server )
677
- end ,
678
- },
687
+ ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via masontool-installer)
688
+ automatic_enable = true , -- automatically run vim.lsp.enable() for all servers that are installed via Mason
679
689
}
690
+ if not vim .tbl_isempty (servers .others ) then
691
+ vim .lsp .enable (vim .tbl_keys (servers .others ))
692
+ end
680
693
end ,
681
694
},
682
695
@@ -925,7 +938,7 @@ require('lazy').setup({
925
938
-- Here are some example plugins that I've included in the Kickstart repository.
926
939
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
927
940
--
928
- -- require 'kickstart.plugins.debug',
941
+ require ' kickstart.plugins.debug' ,
929
942
require ' kickstart.plugins.indent_line' ,
930
943
require ' kickstart.plugins.lint' ,
931
944
require ' kickstart.plugins.autopairs' ,
@@ -1021,3 +1034,6 @@ vim.api.nvim_create_autocmd('BufEnter', {
1021
1034
vim .bo .expandtab = true
1022
1035
end ,
1023
1036
})
1037
+
1038
+ -- The line beneath this is called `modeline`. See `:help modeline`
1039
+ -- vim: ts=2 sts=2 sw=2 et
0 commit comments