mirror of
https://github.com/tomru/vim.git
synced 2026-03-03 06:27:18 +01:00
move to mason_null_ls
This commit is contained in:
@@ -26,6 +26,17 @@ vim.api.nvim_create_autocmd('FileType', {
|
|||||||
group = '_general',
|
group = '_general',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
filter = function(client)
|
||||||
|
return client.name ~= "tsserver"
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
group = "_general",
|
||||||
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
pattern = 'gitcommit,markdown',
|
pattern = 'gitcommit,markdown',
|
||||||
command = 'setlocal wrap spell',
|
command = 'setlocal wrap spell',
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|||||||
if client.name ~= 'tsserver' then
|
if client.name ~= 'tsserver' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
|
||||||
vim.cmd 'EslintFixAll'
|
|
||||||
end, { desc = 'Format current buffer with Eslint' })
|
|
||||||
end,
|
end,
|
||||||
group = '_bcr',
|
group = '_bcr',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
return {
|
|
||||||
"mhartington/formatter.nvim",
|
|
||||||
lazy = false,
|
|
||||||
init = function()
|
|
||||||
vim.api.nvim_create_augroup('_formatter', { clear = true });
|
|
||||||
vim.api.nvim_create_autocmd('BufWritePost', {
|
|
||||||
command = 'FormatWrite',
|
|
||||||
group = '_formatter',
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
opts = function()
|
|
||||||
local filetypes = require('formatter.filetypes')
|
|
||||||
return {
|
|
||||||
logging = false,
|
|
||||||
log_level = vim.log.levels.WARN,
|
|
||||||
filetype = {
|
|
||||||
lua = {
|
|
||||||
filetypes.lua.stylua,
|
|
||||||
},
|
|
||||||
javascript = {
|
|
||||||
filetypes.javascript.eslint_d,
|
|
||||||
},
|
|
||||||
javascriptreact = {
|
|
||||||
filetypes.javascript.eslint_d,
|
|
||||||
},
|
|
||||||
json = {
|
|
||||||
filetypes.json.prettierd,
|
|
||||||
},
|
|
||||||
rust = {
|
|
||||||
filetypes.rust.rustfmt,
|
|
||||||
},
|
|
||||||
['*'] = {
|
|
||||||
filetypes.any.remove_trailing_whitespace,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
||||||
59
lua/custom/plugins/nullls.lua
Normal file
59
lua/custom/plugins/nullls.lua
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
return {
|
||||||
|
"jay-babu/mason-null-ls.nvim",
|
||||||
|
lazy = false,
|
||||||
|
-- event = { "BufReadPre", "BufNewFile" },
|
||||||
|
dependencies = {
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
|
},
|
||||||
|
config = function ()
|
||||||
|
require("mason").setup()
|
||||||
|
require("mason-null-ls").setup({
|
||||||
|
ensure_installed = { 'stylua', 'jq', 'eslint_d' },
|
||||||
|
automatic_setup = false,
|
||||||
|
automatic_installation = false,
|
||||||
|
})
|
||||||
|
local nls = require('null-ls')
|
||||||
|
local diagnostics = nls.builtins.diagnostics
|
||||||
|
local formatting = nls.builtins.formatting
|
||||||
|
local code_actions = nls.builtins.code_actions
|
||||||
|
local h = require("null-ls.helpers")
|
||||||
|
local u = require("null-ls.utils")
|
||||||
|
|
||||||
|
local function eslint_d_cwd(params)
|
||||||
|
return u.root_pattern(
|
||||||
|
-- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
|
||||||
|
".eslintrc",
|
||||||
|
".eslintrc.js",
|
||||||
|
".eslintrc.cjs",
|
||||||
|
".eslintrc.yaml",
|
||||||
|
".eslintrc.yml",
|
||||||
|
".eslintrc.json"
|
||||||
|
-- do not respect package.json
|
||||||
|
-- "package.json",
|
||||||
|
)(params.bufname)
|
||||||
|
end
|
||||||
|
require("null-ls").setup({
|
||||||
|
debug = true,
|
||||||
|
sources = {
|
||||||
|
-- Anything not supported by mason.
|
||||||
|
diagnostics.eslint_d.with({
|
||||||
|
cwd = h.cache.by_bufnr(eslint_d_cwd),
|
||||||
|
-- not sure how to scope this only to bcr's locales
|
||||||
|
extra_filetypes = { "json" },
|
||||||
|
}),
|
||||||
|
formatting.eslint_d.with({
|
||||||
|
cwd = h.cache.by_bufnr(eslint_d_cwd),
|
||||||
|
-- not sure how to scope this only to bcr's locales
|
||||||
|
extra_filetypes = { "json" },
|
||||||
|
}),
|
||||||
|
code_actions.eslint_d.with({
|
||||||
|
cwd = h.cache.by_bufnr(eslint_d_cwd),
|
||||||
|
-- not sure how to scope this only to bcr's locales
|
||||||
|
extra_filetypes = { "json" },
|
||||||
|
}),
|
||||||
|
code_actions.refactoring,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user