@@ -12,7 +12,7 @@ AstroLSP provides a simple API for configuring and setting up language servers i
1212
1313## ⚡️ Requirements
1414
15- - Neovim >= 0.10
15+ - Neovim >= 0.11
1616
1717## 📦 Installation
1818
@@ -89,27 +89,12 @@ local opts = {
8989 desc = " Format file with LSP" ,
9090 },
9191 },
92- -- Configure default capabilities for language servers (`:h vim.lsp.protocol.make_client.capabilities()`)
92+ -- Configure default capabilities for all language servers (`:h vim.lsp.protocol.make_client.capabilities()`)
9393 capabilities = {
9494 textDocument = {
9595 foldingRange = { dynamicRegistration = false },
9696 },
9797 },
98- -- Configure language servers for `lspconfig` (`:h lspconfig-setup`)
99- config = {
100- lua_ls = {
101- settings = {
102- Lua = {
103- hint = { enable = true , arrayIndex = " Disable" },
104- },
105- },
106- },
107- clangd = {
108- capabilities = {
109- offsetEncoding = " utf-8" ,
110- },
111- },
112- },
11398 defaults = {
11499 hover = { border = " rounded" , silent = true } -- customize lsp hover window
115100 signature_help = false , -- disable any default customizations
@@ -158,10 +143,10 @@ local opts = {
158143 },
159144 -- Configure how language servers get set up
160145 handlers = {
161- -- default handler, first entry with no key
162- function ( server , opts ) require ( " lspconfig " )[ server ]. setup ( opts ) end ,
146+ -- default handler uses key "*"
147+ [ " * " ] = vim . lsp . enable ,
163148 -- custom function handler for pyright
164- pyright = function (_ , opts ) require ( " lspconfig " ). pyright . setup ( opts ) end ,
149+ pyright = function () vim . lsp . enable ( " pyright " ) end ,
165150 -- set to false to disable the setup of a language server
166151 rust_analyzer = false ,
167152 },
@@ -198,25 +183,12 @@ local opts = {
198183 },
199184 },
200185 },
201- -- Extra configuration for the `mason-lspconfig.nvim` plugin
202- mason_lspconfig = {
203- -- Allow registering more Mason packages as language servers for autodetection/setup
204- servers = {
205- -- The key is the lspconfig server name to register a package for
206- nextflow_ls = {
207- -- The Mason package name to register to the language server
208- package = " nextflow-language-server" ,
209- -- The filetypes that apply to the package and language server
210- filetypes = { " nextflow" },
211- -- (Optional) any default configuration changes that may need to happen (can be a table or a function that returns a table)
212- config = { cmd = { " nextflow-language-server" } }
213- }
214- }
215- }
216186 -- A list like table of servers that should be setup, useful for enabling language servers not installed with Mason.
217187 servers = { " dartls" },
218188 -- A custom `on_attach` function to be run after the default `on_attach` function, takes two parameters `client` and `bufnr` (`:h lspconfig-setup`)
219- on_attach = function (client , bufnr ) client .server_capabilities .semanticTokensProvider = nil end ,
189+ on_attach = function (client , bufnr )
190+ -- custom on_attach code to run on all servers
191+ end ,
220192}
221193```
222194
@@ -228,43 +200,26 @@ local opts = {
228200
229201``` lua
230202{
231- " neovim/nvim-lspconfig" ,
232- dependencies = {
233- { " AstroNvim/astrolsp" , opts = {} },
234- },
235- config = function ()
236- -- set up servers configured with AstroLSP
237- vim .tbl_map (require (" astrolsp" ).lsp_setup , require (" astrolsp" ).config .servers )
238- end ,
203+ " AstroNvim/astrolsp" ,
204+ dependencies = { " neovim/nvim-lspconfig" },
205+ opts = {}
239206}
240207```
241208
242209### [ nvim-lspconfig] [ lspconfig ] + [ mason.nvim] [ mason ] + [ mason-lspconfig.nvim] [ mason-lspconfig ]
243210
244211``` lua
245212{
246- " neovim/nvim-lspconfig " ,
213+ " AstroNvim/astrolsp " ,
247214 dependencies = {
248- { " AstroNvim/astrolsp " , opts = {} } ,
215+ " neovim/nvim-lspconfig " ,
249216 {
250- " williamboman/mason-lspconfig.nvim" , -- MUST be set up before `nvim-lspconfig`
217+ " williamboman/mason-lspconfig.nvim" ,
251218 dependencies = { " williamboman/mason.nvim" },
252- opts = {
253- -- use AstroLSP setup for mason-lspconfig
254- handlers = { function (server ) require (" astrolsp" ).lsp_setup (server ) end },
255- },
256- config = function (_ , opts )
257- -- Optionally tell AstroLSP to register new language servers before calling the `setup` function
258- -- this enables the `mason-lspconfig.servers` option in the AstroLSP configuration
259- require (" astrolsp.mason-lspconfig" ).register_servers ()
260- require (" mason-lspconfig" ).setup (opts )
261- end
262- },
219+ opts = {}
220+ }
263221 },
264- config = function ()
265- -- set up servers configured with AstroLSP
266- vim .tbl_map (require (" astrolsp" ).lsp_setup , require (" astrolsp" ).config .servers )
267- end ,
222+ opts = {}
268223}
269224```
270225
@@ -276,7 +231,9 @@ local opts = {
276231 dependencies = {
277232 { " AstroNvim/astrolsp" , opts = {} },
278233 },
279- opts = function () return { on_attach = require (" astrolsp" ).on_attach } end ,
234+ opts = {
235+ on_attach = function (client , bufnr ) require (" astrolsp" ).on_attach (client , bufnr ) end
236+ },
280237}
281238```
282239
0 commit comments