Skip to content

Commit

Permalink
feat(astrolsp): move lsp user commands to AstroLSP opts
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Apr 1, 2024
1 parent 1e93c9c commit 2c19d9e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lua/astronvim/plugins/_astrolsp_autocmds.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
local formatting_enabled = function(client)
local formatting_disabled = vim.tbl_get(require("astrolsp").config, "formatting", "disabled")
return client.supports_method "textDocument/formatting"
and formatting_disabled ~= true
and not vim.tbl_contains(formatting_disabled, client.name)
end

return {
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = {
commands = {
Format = {
cond = formatting_enabled,
function() vim.lsp.buf.format(require("astrolsp").format_opts) end,
desc = "Format file with LSP",
},
},
autocmds = {
lsp_codelens_refresh = {
cond = "textDocument/codeLens",
Expand All @@ -14,12 +28,7 @@ return {
},
},
lsp_auto_format = {
cond = function(client)
local config = assert(require("astrolsp").config)
return client.supports_method "textDocument/formatting"
and config.formatting.disabled ~= true
and not vim.tbl_contains(vim.tbl_get(config, "formatting", "disabled"), client.name)
end,
cond = formatting_enabled,
{
event = "BufWritePre",
desc = "autoformat on save",
Expand Down

0 comments on commit 2c19d9e

Please sign in to comment.