diff --git a/dot_config/nvim/after/ftplugin/bash.vim b/dot_config/nvim/after/ftplugin/bash.vim new file mode 100644 index 0000000..b145b5d --- /dev/null +++ b/dot_config/nvim/after/ftplugin/bash.vim @@ -0,0 +1 @@ +set keywordprg=:Man diff --git a/dot_config/nvim/after/ftplugin/sh.vim b/dot_config/nvim/after/ftplugin/sh.vim new file mode 100644 index 0000000..b145b5d --- /dev/null +++ b/dot_config/nvim/after/ftplugin/sh.vim @@ -0,0 +1 @@ +set keywordprg=:Man diff --git a/dot_config/nvim/after/ftplugin/zsh.vim b/dot_config/nvim/after/ftplugin/zsh.vim new file mode 100644 index 0000000..b145b5d --- /dev/null +++ b/dot_config/nvim/after/ftplugin/zsh.vim @@ -0,0 +1 @@ +set keywordprg=:Man diff --git a/dot_config/nvim/lua/configs/packages/conform.lua b/dot_config/nvim/lua/configs/packages/conform.lua new file mode 100644 index 0000000..0bf2dbe --- /dev/null +++ b/dot_config/nvim/lua/configs/packages/conform.lua @@ -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 + '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, +} diff --git a/dot_config/nvim/lua/configs/packages/lint.lua b/dot_config/nvim/lua/configs/packages/lint.lua new file mode 100644 index 0000000..9842cc7 --- /dev/null +++ b/dot_config/nvim/lua/configs/packages/lint.lua @@ -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, +} diff --git a/dot_config/nvim/lua/configs/packages/lsp.lua b/dot_config/nvim/lua/configs/packages/lsp.lua index 38839f3..36085a0 100644 --- a/dot_config/nvim/lua/configs/packages/lsp.lua +++ b/dot_config/nvim/lua/configs/packages/lsp.lua @@ -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', 'cr', 'Trouble lsp_references', mkOpts('LSP references')) vim.keymap.set('n', 'cs', 'Telescope lsp_document_symbols', mkOpts('LSP document symbols')) - vim.keymap.set( - { 'v', 'n' }, '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' }, '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 = { diff --git a/dot_config/nvim/lua/configs/packages/misc.lua b/dot_config/nvim/lua/configs/packages/misc.lua index 02c9619..3b9adad 100644 --- a/dot_config/nvim/lua/configs/packages/misc.lua +++ b/dot_config/nvim/lua/configs/packages/misc.lua @@ -9,15 +9,15 @@ return { { 'ThePrimeagen/harpoon', keys = { - { 'fm', function () require("harpoon.mark").add_file() end, desc = "Harpoon mark file" }, - { 'fh', function () require("harpoon.ui").toggle_quick_menu() end, desc = "Harpoon menu" }, - { '', function () require("harpoon.ui").nav_file(1) end, desc = "Harpoon file 1" }, - { '', function () require("harpoon.ui").nav_file(2) end, desc = "Harpoon file 2" }, - { '', function () require("harpoon.ui").nav_file(3) end, desc = "Harpoon file 3" }, - { '', function () require("harpoon.ui").nav_file(4) end, desc = "Harpoon file 4" }, - { '', function () require("harpoon.ui").nav_file(5) end, desc = "Harpoon file 5" }, + { 'fm', function() require('harpoon.mark').add_file() end, desc = 'Harpoon mark file' }, + { 'fh', function() require('harpoon.ui').toggle_quick_menu() end, desc = 'Harpoon menu' }, + { '', function() require('harpoon.ui').nav_file(1) end, desc = 'Harpoon file 1' }, + { '', function() require('harpoon.ui').nav_file(2) end, desc = 'Harpoon file 2' }, + { '', function() require('harpoon.ui').nav_file(3) end, desc = 'Harpoon file 3' }, + { '', function() require('harpoon.ui').nav_file(4) end, desc = 'Harpoon file 4' }, + { '', 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, }, diff --git a/dot_config/nvim/lua/configs/packages/null-ls.lua b/dot_config/nvim/lua/configs/packages/null-ls.lua index cb230d9..2425d0e 100644 --- a/dot_config/nvim/lua/configs/packages/null-ls.lua +++ b/dot_config/nvim/lua/configs/packages/null-ls.lua @@ -1,5 +1,6 @@ local M = { 'jose-elias-alvarez/null-ls.nvim', + enabled = false, dependencies = { 'nvim-lua/plenary.nvim' }, }