vim lint+format+lsp fixes

This commit is contained in:
Henrik Bakken
2023-09-01 16:11:33 +02:00
parent e24909ddb9
commit fbb0ea717b
+58 -22
View File
@@ -519,11 +519,25 @@ require("lazy").setup({
require("mason").setup()
end,
},
{
"mfussenegger/nvim-lint",
config = function()
require("lint").linters_by_ft = {
javascript = { "eslint_d" },
typescript = { "eslint_d" },
html = { "tidy", "eslint_d" },
}
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})
end,
},
{
"mhartington/formatter.nvim",
-- Utilities for creating configurations
config = function ()
config = function()
local util = require("formatter.util")
local map = vim.keymap.set
local opts = { silent = true, noremap = true }
@@ -538,30 +552,31 @@ require("lazy").setup({
python = {
require("formatter.filetypes.python").black,
-- require("formatter.filetypes.python").pyment,
function ()
function()
return {
exe = "isort",
args = { "--quiet", "--profile black", "--force-single-line-import", "-" },
stdin = true,
}
end,
function ()
function()
return {
exe = "black",
args = { "--quiet", "--preview", "-" },
stdin = true,
}
end,
function ()
function()
return {
exe = "blackdoc",
args = { "-q", "-t py311", },
args = { "-q", "-t py311" },
stdin = false,
}
end,
},
go = { require("formatter.filetypes.go").gofumpt, require("formatter.filetypes.go").golines },
lua = {
function ()
function()
return {
exe = "stylua",
args = {
@@ -577,28 +592,35 @@ require("lazy").setup({
end,
},
yaml = {
function ()
function()
return {
exe = "yamlfmt",
args = { "-formatter indentless_arrays=true,retain_line_breaks=true,line_ending=lf,max_line_length=100,pad_line_comments=2", "-in" },
args = {
"-formatter indentless_arrays=true,retain_line_breaks=true,line_ending=lf,max_line_length=100,pad_line_comments=2",
"-in",
},
stdin = true,
}
end,
},
sh = { require("formatter.filetypes.sh").shfmt, },
typescript = { require("formatter.filetypes.typescript").eslint_d, },
javascript = { require("formatter.filetypes.javascript").eslint_d, },
html = { require("formatter.filetypes.html").prettierd, },
sh = { require("formatter.filetypes.sh").shfmt },
typescript = { require("formatter.filetypes.typescript").eslint_d },
javascript = { require("formatter.filetypes.javascript").eslint_d },
html = {
-- require("formatter.filetypes.html").prettierd,
require("formatter.filetypes.html").tidy,
require("formatter.filetypes.javascript").eslint_d,
},
css = {
require("formatter.filetypes.css").prettierd,
require("formatter.filetypes.css").eslint_d,
},
markdown = { require("formatter.filetypes.markdown").prettierd, },
json = {require("formatter.filetypes.json").jq, },
markdown = { require("formatter.filetypes.markdown").prettierd },
json = { require("formatter.filetypes.json").jq },
["*"] = { require("formatter.filetypes.any").remove_trailing_whitespace },
}
},
})
end
end,
},
{
"neovim/nvim-lspconfig",
@@ -625,10 +647,10 @@ require("lazy").setup({
vim.diagnostic.open_float({ source = true })
end)
bmap("n", "<M-n>", function()
vim.diagnostic.goto_next({ severity = { min = vim.diagnostic.severity.INFO } })
vim.diagnostic.goto_next({ severity = { min = vim.diagnostic.severity.HINT } })
end)
bmap("n", "<M-p>", function()
vim.diagnostic.goto_prev({ severity = { min = vim.diagnostic.severity.INFO } })
vim.diagnostic.goto_prev({ severity = { min = vim.diagnostic.severity.HINT } })
end)
bmap("n", "gd", vim.lsp.buf.definition)
bmap("n", "gD", vim.lsp.buf.type_definition)
@@ -669,7 +691,20 @@ require("lazy").setup({
-- Get the language server to recognize the `vim` global in init.lua
globals = { "vim" },
},
format = {enable = false},
format = { enable = false },
},
},
html = {
html = {
format = {
templating = true,
wrapLineLength = 120,
wrapAttributes = "auto",
},
hover = {
documentation = true,
references = true,
},
},
},
}
@@ -683,7 +718,6 @@ require("lazy").setup({
ensure_installed = {
"bashls", -- bash
"cssls", -- css
"eslint", -- javascript
"html", -- html
"jsonls", -- json
"lua_ls", -- lua
@@ -768,6 +802,8 @@ vim.o.expandtab = true -- Use spaces instead of tabs
vim.o.shiftround = true -- Round indent
vim.o.tabstop = 4 -- Number of spaces tabs count for
vim.o.shiftwidth = 4 -- Size of an indent
vim.o.listchars = "tab:→ ,trail:·,extends:↷,precedes:↶,nbsp:+,eol:↵"
vim.o.list = true -- Show listchars
-- search
vim.opt.wildmode = { "full" } -- Command-line completion mode
@@ -794,7 +830,7 @@ vim.o.foldenable = false
vim.o.foldmethod = "expr"
vim.o.completeopt = "menu,menuone,noinsert"
vim.opt.formatoptions = vim.opt.formatoptions - {"c", "r", "o"}
vim.opt.formatoptions = vim.opt.formatoptions - { "c", "r", "o" }
-- press enter in quickfix list to goto
vim.api.nvim_command([[augroup MYAU]])