14
14
-- ━━━━━━━━━━━━━━━━━━━❰ configs ❱━━━━━━━━━━━━━━━━━━━ --
15
15
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
16
16
17
- local lspinstaller_imported , lspinstaller = pcall (require , ' nvim-lsp-installer' )
18
- if not lspinstaller_imported then return end
17
+ local M = {}
19
18
19
+ M .setup = {
20
20
21
- lspinstaller .setup {
21
+ -- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer", "sumneko_lua" }
22
+ -- This setting has no relation with the `automatic_installation` setting.
23
+ -- ensure_installed = {"sumneko_lua"},
22
24
23
- -- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer", "sumneko_lua" }
24
- -- This setting has no relation with the `automatic_installation` setting.
25
- -- ensure_installed = {"sumneko_lua"},
26
-
27
- -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed.
28
- -- This setting has no relation with the `ensure_installed` setting.
29
- -- Can either be:
30
- -- - false: Servers are not automatically installed.
31
- -- - true: All servers set up via lspconfig are automatically installed.
32
- -- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed.
33
- -- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } }
34
- automatic_installation = false ,
25
+ -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed.
26
+ -- This setting has no relation with the `ensure_installed` setting.
27
+ -- Can either be:
28
+ -- - false: Servers are not automatically installed.
29
+ -- - true: All servers set up via lspconfig are automatically installed.
30
+ -- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed.
31
+ -- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } }
32
+ automatic_installation = false ,
35
33
36
34
ui = {
37
35
-- Whether to automatically check for outdated servers when opening the UI window.
@@ -43,22 +41,22 @@ lspinstaller.setup{
43
41
server_pending = " ➜" ,
44
42
server_uninstalled = " ✗" ,
45
43
},
46
- keymaps = {
47
- -- Keymap to expand a server in the UI
48
- toggle_server_expand = " <CR>" ,
49
- -- Keymap to install the server under the current cursor position
50
- install_server = " i" ,
51
- -- Keymap to reinstall/update the server under the current cursor position
52
- update_server = " u" ,
53
- -- Keymap to check for new version for the server under the current cursor position
54
- check_server_version = " c" ,
55
- -- Keymap to update all installed servers
56
- update_all_servers = " U" ,
57
- -- Keymap to check which installed servers are outdated
58
- check_outdated_servers = " C" ,
59
- -- Keymap to uninstall a server
60
- uninstall_server = " X" ,
61
- },
44
+ keymaps = {
45
+ -- Keymap to expand a server in the UI
46
+ toggle_server_expand = " <CR>" ,
47
+ -- Keymap to install the server under the current cursor position
48
+ install_server = " i" ,
49
+ -- Keymap to reinstall/update the server under the current cursor position
50
+ update_server = " u" ,
51
+ -- Keymap to check for new version for the server under the current cursor position
52
+ check_server_version = " c" ,
53
+ -- Keymap to update all installed servers
54
+ update_all_servers = " U" ,
55
+ -- Keymap to check which installed servers are outdated
56
+ check_outdated_servers = " C" ,
57
+ -- Keymap to uninstall a server
58
+ uninstall_server = " X" ,
59
+ },
62
60
},
63
61
64
62
-- The directory in which to install all servers.
@@ -73,79 +71,7 @@ lspinstaller.setup{
73
71
max_concurrent_installers = 4 ,
74
72
}
75
73
76
-
77
- -- ───────────────────────────────────────────────── --
78
- -- setup LSPs manually
79
- -- ───────────────────────────────────────────────── --
80
- local installed_servers = lspinstaller .get_installed_servers ()
81
- -- don't setup servers if atleast one server is installed, or it will throw an error
82
- if # installed_servers == 0 then return end
83
-
84
- -- always call require("lspconfig") after require("nvim-lsp-installer").setup {}, this is the way
85
- local lspconfig_imported , lspconfig = pcall (require , ' lspconfig' )
86
- if not lspconfig_imported then return end
87
-
88
- local capabilities = vim .lsp .protocol .make_client_capabilities ()
89
- -- import lsp configs/options which are managed in seprate file, nvim-lspconfig.lua
90
- local lsp_options = require (" plugins.nvim-lspconfig" ).options
91
-
92
-
93
- for _ , server in ipairs (installed_servers ) do
94
-
95
- -- for lua
96
- if server .name == " sumneko_lua" then
97
- lsp_options .settings = {
98
- Lua = {
99
- diagnostics = {
100
- -- Get the language server to recognize the 'vim', 'use' global
101
- globals = {' vim' , ' use' , ' require' },
102
- },
103
- workspace = {
104
- -- Make the server aware of Neovim runtime files
105
- library = vim .api .nvim_get_runtime_file (" " , true ),
106
- },
107
- -- Do not send telemetry data containing a randomized but unique identifier
108
- telemetry = {enable = false },
109
- },
110
- }
111
- end
112
-
113
- -- for clangd (c/c++)
114
- -- [https://github.com/jose-elias-alvarez/null-ls.nvim/issues/428]
115
- if server .name == " clangd" then
116
- capabilities .offsetEncoding = { " utf-16" }
117
- lsp_options .capabilities = capabilities
118
- end
119
-
120
- -- for html
121
- if server .name == " html" then
122
- lsp_options .filetypes = {" html" , " htmldjango" }
123
- end
124
-
125
- -- for css / scss / sass
126
- if server .name == " cssls" then
127
-
128
- --[==[
129
- Neovim does not currently include built-in snippets.
130
- `vscode-css-language-server` only provides completions when snippet support is enabled.
131
- To enable completion, install a snippet plugin and add the following override to your
132
- language client capabilities during setup. Enable (broadcasting) snippet capability for completion
133
- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/cssls.lua
134
- --]==]
135
- capabilities .textDocument .completion .completionItem .snippetSupport = true
136
- lsp_options .capabilities = capabilities
137
- end
138
-
139
- lspconfig [server .name ].setup (lsp_options )
140
- end
141
-
142
- -- for Flutter and Dart
143
- -- don't put this on loop to set it because dart LSP installed and maintained by akinsho/flutter-tools.nvim
144
- lspconfig [" dartls" ].setup (lsp_options )
145
- -- ───────────────────────────────────────────────── --
146
- -- end LSP setup
147
- -- ───────────────────────────────────────────────── --
148
-
74
+ return M
149
75
150
76
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ --
151
77
-- ━━━━━━━━━━━━━━━━━❰ end configs ❱━━━━━━━━━━━━━━━━━ --
0 commit comments