nvim: null-ls -> conform & lint
This commit is contained in:
parent
807c89c526
commit
5f325914b9
8 changed files with 149 additions and 21 deletions
1
dot_config/nvim/after/ftplugin/bash.vim
Normal file
1
dot_config/nvim/after/ftplugin/bash.vim
Normal file
|
@ -0,0 +1 @@
|
|||
set keywordprg=:Man
|
1
dot_config/nvim/after/ftplugin/sh.vim
Normal file
1
dot_config/nvim/after/ftplugin/sh.vim
Normal file
|
@ -0,0 +1 @@
|
|||
set keywordprg=:Man
|
1
dot_config/nvim/after/ftplugin/zsh.vim
Normal file
1
dot_config/nvim/after/ftplugin/zsh.vim
Normal file
|
@ -0,0 +1 @@
|
|||
set keywordprg=:Man
|
88
dot_config/nvim/lua/configs/packages/conform.lua
Normal file
88
dot_config/nvim/lua/configs/packages/conform.lua
Normal file
|
@ -0,0 +1,88 @@
|
|||
local ensure = {
|
||||
'hadolint',
|
||||
'php-cs-fixer',
|
||||
'ansible-lint',
|
||||
}
|
||||
|
||||
return {
|
||||
'stevearc/conform.nvim',
|
||||
cmd = { 'ConformInfo' },
|
||||
keys = {
|
||||
{
|
||||
-- Customize or remove this keymap to your liking
|
||||
'<leader>F',
|
||||
function()
|
||||
require('conform').format({ async = true, lsp_fallback = true })
|
||||
end,
|
||||
mode = '',
|
||||
desc = 'Format buffer',
|
||||
},
|
||||
},
|
||||
-- Everything in opts will be passed to setup()
|
||||
opts = {
|
||||
-- Define your formatters
|
||||
formatters_by_ft = {
|
||||
-- lua = { "stylua" },
|
||||
-- javascript = { { "prettierd", "prettier" } },
|
||||
dockerfile = { 'hadolint' },
|
||||
php = { 'php_cs_fixer' },
|
||||
json = { 'jq' },
|
||||
just = { 'just' },
|
||||
},
|
||||
-- Set up format-on-save
|
||||
-- format_on_save = { timeout_ms = 500, lsp_fallback = true },
|
||||
-- Customize formatters
|
||||
formatters = {
|
||||
php_cs_fixer = { ---{{{
|
||||
args = {
|
||||
'fix',
|
||||
'--rules',
|
||||
[[{
|
||||
"@Symfony": true,
|
||||
"fully_qualified_strict_types": false,
|
||||
"array_syntax": {
|
||||
"syntax": "short"
|
||||
},
|
||||
"nullable_type_declaration_for_default_null_value": true,
|
||||
"binary_operator_spaces": {
|
||||
"default": "single_space",
|
||||
"operators": {
|
||||
">>=": "align_single_space_minimal",
|
||||
"<<=": "align_single_space_minimal",
|
||||
"/=": "align_single_space_minimal",
|
||||
"*=": "align_single_space_minimal",
|
||||
"^=": "align_single_space_minimal",
|
||||
"%=": "align_single_space_minimal",
|
||||
"=>": "align_single_space_minimal",
|
||||
"|=": "align_single_space_minimal",
|
||||
".=": "align_single_space_minimal",
|
||||
"<=": "align_single_space_minimal",
|
||||
">=": "align_single_space_minimal",
|
||||
"+=": "align_single_space_minimal",
|
||||
"**=": "align_single_space_minimal",
|
||||
"&=": "align_single_space_minimal",
|
||||
"=": "align_single_space_minimal",
|
||||
"-=": "align_single_space_minimal",
|
||||
"??=": "align_single_space_minimal"
|
||||
}
|
||||
}
|
||||
}]],
|
||||
'$FILENAME',
|
||||
},
|
||||
}, -- }}}
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
for _, pkg in pairs(ensure) do
|
||||
local p = require('mason-registry').get_package(pkg)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
end
|
||||
end
|
||||
require('conform').setup(opts)
|
||||
end,
|
||||
init = function()
|
||||
-- If you want the formatexpr, here is the place to set it
|
||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||
end,
|
||||
}
|
31
dot_config/nvim/lua/configs/packages/lint.lua
Normal file
31
dot_config/nvim/lua/configs/packages/lint.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
local ensure = {
|
||||
'shellcheck',
|
||||
'hadolint',
|
||||
'phpstan',
|
||||
}
|
||||
|
||||
return {
|
||||
'mfussenegger/nvim-lint',
|
||||
event = 'BufWritePre',
|
||||
opts = {
|
||||
sh = { 'shellcheck' },
|
||||
bash = { 'shellcheck' },
|
||||
php = { 'phpstan' },
|
||||
dockerfile = { 'hadolint' },
|
||||
},
|
||||
config = function(_, opts)
|
||||
for _, pkg in pairs(ensure) do
|
||||
local p = require('mason-registry').get_package(pkg)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
end
|
||||
end
|
||||
require('lint').linters_by_ft = opts
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
|
||||
callback = function()
|
||||
require('lint').try_lint()
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -221,16 +221,16 @@ local function on_attach(args) -- {{{
|
|||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, mkOpts('LSP references'))
|
||||
vim.keymap.set('n', '<leader>cr', '<Cmd>Trouble lsp_references<CR>', mkOpts('LSP references'))
|
||||
vim.keymap.set('n', '<leader>cs', '<Cmd>Telescope lsp_document_symbols<CR>', mkOpts('LSP document symbols'))
|
||||
vim.keymap.set(
|
||||
{ 'v', 'n' }, '<leader>F', function()
|
||||
vim.lsp.buf.format({ async = true, filter = formatting_filter })
|
||||
end,
|
||||
mkOpts('Lsp Format')
|
||||
)
|
||||
|
||||
if (formatting_filter(client)) then
|
||||
vim.api.nvim_set_option_value('formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})', { buf = bufnr })
|
||||
end
|
||||
-- vim.keymap.set(
|
||||
-- { 'v', 'n' }, '<leader>F', function()
|
||||
-- vim.lsp.buf.format({ async = true, filter = formatting_filter })
|
||||
-- end,
|
||||
-- mkOpts('Lsp Format')
|
||||
-- )
|
||||
--
|
||||
-- if (formatting_filter(client)) then
|
||||
-- vim.api.nvim_set_option_value('formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})', { buf = bufnr })
|
||||
-- end
|
||||
|
||||
if client.name == 'omnisharp' then
|
||||
client.server_capabilities.semanticTokensProvider.legend = {
|
||||
|
|
|
@ -9,15 +9,15 @@ return {
|
|||
{
|
||||
'ThePrimeagen/harpoon',
|
||||
keys = {
|
||||
{ '<leader>fm', function () require("harpoon.mark").add_file() end, desc = "Harpoon mark file" },
|
||||
{ '<leader>fh', function () require("harpoon.ui").toggle_quick_menu() end, desc = "Harpoon menu" },
|
||||
{ '<C-1>', function () require("harpoon.ui").nav_file(1) end, desc = "Harpoon file 1" },
|
||||
{ '<C-2>', function () require("harpoon.ui").nav_file(2) end, desc = "Harpoon file 2" },
|
||||
{ '<C-3>', function () require("harpoon.ui").nav_file(3) end, desc = "Harpoon file 3" },
|
||||
{ '<C-4>', function () require("harpoon.ui").nav_file(4) end, desc = "Harpoon file 4" },
|
||||
{ '<C-5>', function () require("harpoon.ui").nav_file(5) end, desc = "Harpoon file 5" },
|
||||
{ '<leader>fm', function() require('harpoon.mark').add_file() end, desc = 'Harpoon mark file' },
|
||||
{ '<leader>fh', function() require('harpoon.ui').toggle_quick_menu() end, desc = 'Harpoon menu' },
|
||||
{ '<C-1>', function() require('harpoon.ui').nav_file(1) end, desc = 'Harpoon file 1' },
|
||||
{ '<C-2>', function() require('harpoon.ui').nav_file(2) end, desc = 'Harpoon file 2' },
|
||||
{ '<C-3>', function() require('harpoon.ui').nav_file(3) end, desc = 'Harpoon file 3' },
|
||||
{ '<C-4>', function() require('harpoon.ui').nav_file(4) end, desc = 'Harpoon file 4' },
|
||||
{ '<C-5>', function() require('harpoon.ui').nav_file(5) end, desc = 'Harpoon file 5' },
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -194,9 +194,14 @@ return {
|
|||
local lines = require('lsp_lines')
|
||||
lines.setup()
|
||||
vim.diagnostic.config({
|
||||
virtual_lines = {
|
||||
only_current_line = true
|
||||
},
|
||||
virtual_lines = function(ns, bufnr)
|
||||
local ft = vim.api.nvim_get_option_value('filetype', { buf = bufnr })
|
||||
if ft == 'lazy' then
|
||||
return false
|
||||
else
|
||||
return { only_current_line = true }
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
local M = {
|
||||
'jose-elias-alvarez/null-ls.nvim',
|
||||
enabled = false,
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue