-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace none-ls with conform and nvim-lint
- Loading branch information
1 parent
bb106c3
commit a2b173d
Showing
4 changed files
with
126 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
return { | ||
"stevearc/conform.nvim", | ||
event = { "BufWritePre" }, | ||
cmd = { "ConformInfo" }, | ||
keys = { | ||
{ | ||
-- Customize or remove this keymap to your liking | ||
"<leader>fmt", | ||
function() | ||
require("conform").format({ async = true }) | ||
end, | ||
mode = "", | ||
desc = "Format buffer", | ||
}, | ||
}, | ||
-- This will provide type hinting with LuaLS | ||
---@module "conform" | ||
---@type conform.setupOpts | ||
opts = { | ||
-- Define your formatters | ||
formatters_by_ft = { | ||
lua = { "stylua" }, | ||
python = { "isort", "black" }, | ||
rust = { "rustfmt", lsp_format = "fallback" }, | ||
javascript = { "eslint_d", "prettierd", "prettier", stop_after_first = true }, | ||
typescript = { "eslint_d", "prettier", stop_after_first = true }, | ||
javascriptreact = { "eslint_d", "prettier", stop_after_first = true }, | ||
typescriptreact = { "eslint_d", "prettier", stop_after_first = true }, | ||
svelte = { "prettier" }, | ||
css = { "prettier" }, | ||
html = { "prettier" }, | ||
json = { "prettier" }, | ||
yaml = { "prettier" }, | ||
markdown = { "prettier" }, | ||
graphql = { "prettier" }, | ||
go = { "goimports", "gofmt" }, | ||
ruby = { "rubocop" }, | ||
}, | ||
-- Set default options | ||
default_format_opts = { | ||
lsp_format = "fallback", | ||
}, | ||
-- Set up format-on-save | ||
-- format_on_save = { timeout_ms = 500 }, | ||
-- Customize formatters | ||
formatters = { | ||
shfmt = { | ||
prepend_args = { "-i", "2" }, | ||
}, | ||
}, | ||
}, | ||
init = function() | ||
-- If you want the formatexpr, here is the place to set it | ||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
return { | ||
"mfussenegger/nvim-lint", | ||
event = { | ||
"BufReadPre", | ||
"BufNewFile", | ||
}, | ||
config = function() | ||
local lint = require("lint") | ||
|
||
lint.linters_by_ft = { | ||
javascript = { "eslint_d" }, | ||
typescript = { "eslint_d" }, | ||
javascriptreact = { "eslint_d" }, | ||
typescriptreact = { "eslint_d" }, | ||
svelte = { "eslint_d" }, | ||
python = { "pylint" }, | ||
ruby = { "rubocop" }, | ||
go = { "golangcilint" }, | ||
fish = { "fish" }, | ||
jsonlint = { "jsonlint" }, | ||
} | ||
|
||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) | ||
|
||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { | ||
group = lint_augroup, | ||
callback = function() | ||
lint.try_lint() | ||
end, | ||
}) | ||
|
||
vim.keymap.set("n", "<leader><space>l", function() | ||
lint.try_lint() | ||
end, { desc = "Trigger linting for current file" }) | ||
end, | ||
} |