You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hello, a pretty basic feature request actually. is it possible to add an LSP formatter? some language servers implement formatting, and when I'm writing code using those lsp's, i always prefer formatting with the lsp.using the following command :lua vim.lsp.buf.formatting()
all languages are handled through that one command, so would it be possible to add an option for adding lsp formatting as the default?
The text was updated successfully, but these errors were encountered:
I needed to use LSP formatter for Lua and neoformat for Python and wrote a wrapper around neoformat. It checks global variable neoformat_enabled_* for the current buffer and calls neoformat if it exists. Of course, one can set up additional logic.
Here's my neoformat config
vim.g.neoformat_enabled_python = { 'yapf' }
local ext_to_lang = {
py = "python",
lua = "lua",
rs = "rust",
}
local function format()
local buf = vim.api.nvim_get_current_buf()
local name = vim.api.nvim_buf_get_name(buf)
local ext = name:match("%.(%w+)$")
local lang = ext_to_lang[ext]
if lang then
local key = "neoformat_enabled_" .. lang
if vim.g[key] then
vim.cmd("Neoformat")
return
end
end
vim.lsp.buf.format()
end
vim.keymap.set('n', '<leader>m', format, { desc = "Format buf with Neoformat or ls" })
hello, a pretty basic feature request actually. is it possible to add an LSP formatter? some language servers implement formatting, and when I'm writing code using those lsp's, i always prefer formatting with the lsp.using the following command
:lua vim.lsp.buf.formatting()
all languages are handled through that one command, so would it be possible to add an option for adding lsp formatting as the default?
The text was updated successfully, but these errors were encountered: