Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): create a proper way of removing items from skipped_servers #2503

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ lvim.lsp.diagnostics.virtual_text = false
-- See the full default list `:lua print(vim.inspect(lvim.lsp.override))`
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" })

-- remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!!
-- LvimInfo` lists which server(s) are skiipped for the current filetype
local tbl = require "lvim.utils.table"
tbl.remove(lvim.lsp.automatic_configuration.skipped_servers, "tailwindcss")

-- set a formatter, this will override the language server formatting capabilities (if it exists)
local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
Expand Down
14 changes: 14 additions & 0 deletions lua/lvim/utils/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@ function Table.contains(t, predicate)
return Table.find_first(t, predicate) ~= nil
end

-- Remove item from table by it's value
-- @param t The table
-- @param value The item to remove
-- @return True if item was removed, false otherwise
function Table.remove(t, value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutation a function input is a bad idea. Built-in table filter has a better API in my opinion. Creating a new table and returning that is the best and safest way to proceed.

for i, v in ipairs(t) do
if v == value then
table.remove(t, i)
return true
end
end
return false
end

return Table
5 changes: 2 additions & 3 deletions utils/installer/config.example.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ lvim.builtin.treesitter.highlight.enabled = true

-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!!
-- ---`:LvimInfo` lists which server(s) are skiipped for the current filetype
-- vim.tbl_map(function(server)
-- return server ~= "emmet_ls"
-- end, lvim.lsp.automatic_configuration.skipped_servers)
-- local tbl = require "lvim.utils.table"
-- tbl.remove(lvim.lsp.automatic_configuration.skipped_servers, "emmet_ls")

-- -- you can set a custom on_attach function that will be used for all the language servers
-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion>
Expand Down
5 changes: 2 additions & 3 deletions utils/installer/config_win.example.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ lvim.builtin.treesitter.highlight.enabled = true

-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!!
-- ---`:LvimInfo` lists which server(s) are skiipped for the current filetype
-- vim.tbl_map(function(server)
-- return server ~= "emmet_ls"
-- end, lvim.lsp.automatic_configuration.skipped_servers)
-- local tbl = require "lvim.utils.table"
-- tbl.remove(lvim.lsp.automatic_configuration.skipped_servers, "emmet_ls")

-- -- you can set a custom on_attach function that will be used for all the language servers
-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion>
Expand Down