mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-07-02 01:39:26 +00:00
[neovim] Use conform plugin for auto formatting
This commit is contained in:
@ -45,9 +45,9 @@ cmp.setup({
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-q>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm(),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
cmp.select_next_item()
|
||||
end),
|
||||
-- ["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- cmp.select_next_item()
|
||||
-- end),
|
||||
["<C-CR>"] = function(fallback)
|
||||
cmp.abort()
|
||||
fallback()
|
||||
|
@ -28,6 +28,7 @@ dapui.setup({
|
||||
})
|
||||
|
||||
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
|
||||
vim.fn.sign_define("DapStopped", { text = "", texthl = "DiagnosticSignWarn", linehl = "", numhl = "" })
|
||||
|
||||
dap.listeners.after.event_initialized.dapui_config = function()
|
||||
dapui.open()
|
||||
|
@ -8,15 +8,3 @@ require("go").setup({
|
||||
require("guihua.maps").setup({
|
||||
maps = { close_view = "<C-x>" },
|
||||
})
|
||||
|
||||
vim.cmd("autocmd FileType go nmap <Leader>gf :lua require('go.format').goimport()<CR>")
|
||||
|
||||
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*.go",
|
||||
callback = function()
|
||||
require('go.format').goimports()
|
||||
end,
|
||||
group = format_sync_grp,
|
||||
})
|
||||
|
||||
|
26
.config/nvim/lua/plugins/lsp/conform.lua
Normal file
26
.config/nvim/lua/plugins/lsp/conform.lua
Normal file
@ -0,0 +1,26 @@
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
go = { "goimports", "gofumpt" },
|
||||
javascript = { "prettier" },
|
||||
json = { "prettier" },
|
||||
lua = { "stylua" },
|
||||
markdown = { "prettier" },
|
||||
python = { "isort", "black" },
|
||||
typescript = { "prettier" },
|
||||
yaml = { "prettier" },
|
||||
},
|
||||
formatters = {
|
||||
{
|
||||
command = "black",
|
||||
args = { "--line-length", "100" },
|
||||
},
|
||||
},
|
||||
format_on_save = function(bufnr)
|
||||
local filetypes = { "go", "typescript", "lua" }
|
||||
if not vim.tbl_contains(filetypes, vim.bo[bufnr].filetype) then
|
||||
return
|
||||
end
|
||||
|
||||
return { timeout_ms = 500, lsp_fallback = false }
|
||||
end,
|
||||
})
|
@ -1,6 +1,7 @@
|
||||
require("plugins.lsp.mason")
|
||||
require("plugins.lsp.handlers").setup()
|
||||
require("plugins.lsp.none-ls")
|
||||
require("plugins.lsp.conform")
|
||||
require("plugins.lsp.lsp-saga")
|
||||
|
||||
local win = require("lspconfig.ui.windows")
|
||||
|
@ -1,6 +1,4 @@
|
||||
local none_ls = require("null-ls")
|
||||
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/formatting
|
||||
local formatting = none_ls.builtins.formatting
|
||||
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
|
||||
local diagnostics = none_ls.builtins.diagnostics
|
||||
|
||||
@ -13,11 +11,6 @@ end
|
||||
none_ls.setup({
|
||||
debug = false,
|
||||
sources = {
|
||||
formatting.black.with({
|
||||
extra_args = { "--fast", "--line-length", "100" },
|
||||
}),
|
||||
formatting.stylua,
|
||||
formatting.prettier,
|
||||
diagnostics.hadolint,
|
||||
diagnostics.markdownlint,
|
||||
diagnostics.revive.with({
|
||||
|
Reference in New Issue
Block a user