Set up conform.nvim
This commit is contained in:
parent
445c5965c6
commit
e6f397f4be
11 changed files with 68 additions and 77 deletions
home/features/neovim/config/lua/my/plugins
|
@ -1,42 +0,0 @@
|
|||
local env = require("my.helpers.env")
|
||||
local K = require("my.keymaps")
|
||||
|
||||
local M = {
|
||||
"mhartington/formatter.nvim",
|
||||
event = "BufReadPre",
|
||||
cond = env.vscode.not_active(),
|
||||
}
|
||||
|
||||
function M.config()
|
||||
local any = require("formatter.filetypes.any")
|
||||
local formatters = {
|
||||
markdown = {
|
||||
require("formatter.filetypes.markdown").prettier,
|
||||
},
|
||||
lua = {
|
||||
require("formatter.filetypes.lua").stylua,
|
||||
},
|
||||
["*"] = {
|
||||
any.remove_trailing_whitespace,
|
||||
},
|
||||
}
|
||||
|
||||
require("formatter").setup({ filetype = formatters })
|
||||
|
||||
local format = function()
|
||||
if formatters[vim.bo.filetype] ~= nil then
|
||||
vim.cmd([[Format]])
|
||||
elseif next(vim.lsp.get_active_clients({ bufnr = 0 })) == nil then
|
||||
vim.lsp.buf.format()
|
||||
end
|
||||
end
|
||||
|
||||
K.nmap("<leader>F", format, "[F]ormat file")
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("Formatting", { clear = false }),
|
||||
callback = format,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
|
@ -42,14 +42,14 @@ function M.on_attach(client, bufnr)
|
|||
vim.lsp.buf.format({ async = false, bufnr = bufnr })
|
||||
end
|
||||
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
nmap("<leader>F", format, "[F]ormat")
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }),
|
||||
buffer = bufnr,
|
||||
callback = format,
|
||||
})
|
||||
end
|
||||
-- if client.supports_method("textDocument/formatting") then
|
||||
-- nmap("<leader>F", format, "[F]ormat")
|
||||
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
-- group = vim.api.nvim_create_augroup("LspFormatting", { clear = false }),
|
||||
-- buffer = bufnr,
|
||||
-- callback = format,
|
||||
-- })
|
||||
-- end
|
||||
-- }}}
|
||||
-- {{{ Go to declaration / references / implementation
|
||||
nmap("gd", vim.lsp.buf.definition, "[G]o to [d]efinition")
|
||||
|
@ -129,6 +129,10 @@ local servers = {
|
|||
settings = {
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
Lua = {
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
format = {
|
||||
enable = true
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
|
@ -211,9 +215,9 @@ function lspconfig.config()
|
|||
diagnostics_icons()
|
||||
-- -- {{{ Change on-hover borders
|
||||
vim.lsp.handlers["textDocument/hover"] =
|
||||
vim.lsp.with(vim.lsp.handlers.hover, { border = "single" })
|
||||
vim.lsp.with(vim.lsp.handlers.hover, { border = "single" })
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] =
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" })
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" })
|
||||
-- -- }}}
|
||||
|
||||
local capabilities = M.capabilities()
|
||||
|
@ -226,7 +230,7 @@ function lspconfig.config()
|
|||
|
||||
require("lspconfig")[lsp].setup({
|
||||
on_attach = details.on_attach,
|
||||
settings = details.settings, -- Specific per-language settings
|
||||
settings = details.settings, -- Specific per-language settings
|
||||
flags = {
|
||||
debounce_text_changes = 150, -- This will be the default in neovim 0.7+
|
||||
},
|
||||
|
|
|
@ -13,21 +13,7 @@ function M.config()
|
|||
local null_ls = require("null-ls")
|
||||
|
||||
local sources = {
|
||||
-- {{{ Typescript formatting
|
||||
-- null_ls.builtins.formatting.prettierd, -- format ts files
|
||||
null_ls.builtins.formatting.prettier, -- format ts files
|
||||
-- }}}
|
||||
-- {{{ Lua formatting
|
||||
-- null_ls.builtins.formatting, -- format lua code
|
||||
null_ls.builtins.formatting.stylua, -- format lua code
|
||||
-- }}}
|
||||
-- {{{ Python
|
||||
-- Formatting:
|
||||
-- null_ls.builtins.formatting.black,
|
||||
-- null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.yapf.with({
|
||||
extra_args = { [[--style="{ indent_width: 2 }"]] },
|
||||
}),
|
||||
-- Diagnostics
|
||||
null_ls.builtins.diagnostics.ruff, -- Linting
|
||||
-- null_ls.builtins.diagnostics.mypy, -- Type checking
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue