Skip to content

Commit

Permalink
perf(lsp): add xml ls
Browse files Browse the repository at this point in the history
  • Loading branch information
liubang committed May 20, 2024
1 parent 00b6725 commit 239f479
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
38 changes: 17 additions & 21 deletions lua/plugins/lsp/format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,26 @@ function M.format()
vim.lsp.buf.format({ async = false, bufnr = bufnr, filter = filter })
end

function M.on_attach(client, bufnr)
function M.on_attach(_, bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
if client.supports_method("textDocument/formatting") then
vim.keymap.set("n", "<Leader>fm", function()
M.format()
end, opts)

-- auto format
if autoformats[vim.bo[bufnr].filetype] then
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("LspFormat." .. bufnr, {}),
buffer = bufnr,
callback = function()
M.format()
end,
})
end
vim.keymap.set("n", "<Leader>fm", function()
M.format()
end, opts)

-- auto format
if autoformats[vim.bo[bufnr].filetype] then
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("LspFormat." .. bufnr, {}),
buffer = bufnr,
callback = function()
M.format()
end,
})
end

if client.supports_method("textDocument/rangeFormatting") then
vim.keymap.set("v", "<Leader>fm", function()
M.format()
end, opts)
end
vim.keymap.set("v", "<Leader>fm", function()
M.format()
end, opts)
end

return M
4 changes: 1 addition & 3 deletions lua/plugins/lsp/servers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ for _, server in ipairs({
end

for _, server in ipairs({
-- "html",
-- "cssls",
-- "emmet_ls", -- emmet YYDS!
"lemminx",
"thriftls",
"taplo", -- for toml
"bashls",
Expand Down

0 comments on commit 239f479

Please sign in to comment.