diff --git a/flake.nix b/flake.nix index c9a0c03..eaec499 100644 --- a/flake.nix +++ b/flake.nix @@ -31,9 +31,9 @@ pkgs = import nixpkgs { inherit system; overlays = [ - neovim-overlay inputs.neovim-nightly-overlay.overlays.default gen-luarc.overlays.default + neovim-overlay ]; }; shell = pkgs.mkShell { diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index b3c7409..caa4247 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -16,6 +16,7 @@ with final.pkgs.lib; let blink-cmp blink-ripgrep-nvim codecompanion-nvim + conform-nvim copilot-lua diffview-nvim eyeliner-nvim @@ -25,12 +26,12 @@ with final.pkgs.lib; let luasnip mini-nvim neogit - none-ls-nvim nightfox-nvim nvim-autopairs # nvim-dap # nvim-dap-go # nvim-dap-ui + nvim-lint nvim-lspconfig # nvim-nio nvim-treesitter-context @@ -52,6 +53,7 @@ with final.pkgs.lib; let # linters puppet-lint yamllint + jq # LSPs gopls diff --git a/nvim/lua/config/init.lua b/nvim/lua/config/init.lua index 09e91cb..31dd5be 100644 --- a/nvim/lua/config/init.lua +++ b/nvim/lua/config/init.lua @@ -1,5 +1,6 @@ +vim.opt.autowrite = true vim.opt.backspace = 'indent,eol,start' -vim.opt.clipboard = 'unnamedplus' +vim.opt.confirm = true vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } vim.opt.expandtab = true -- insert tabs as spaces vim.opt.inccommand = 'split' -- incremental live completion @@ -80,7 +81,7 @@ vim.diagnostic.config { -- random keymaps vim.keymap.set('n', 'gq', vim.cmd.bdelete, { silent = true }) -vim.keymap.set('n', 'gQ', '%bd|e#', { silent = true }) +vim.keymap.set('n', 'gQ', '%bd|e#', { silent = true }) vim.keymap.set('n', 'gt', vim.cmd.bnext, { silent = true }) vim.keymap.set('n', 'gr', vim.cmd.bprev, { silent = true }) vim.keymap.set('n', 'tr', 'gT', { noremap = true, silent = true }) @@ -88,4 +89,30 @@ vim.keymap.set('n', 'tt', 'gt', { noremap = true, silent = true }) vim.keymap.set('n', 'n', 'nzz', { noremap = true, silent = true }) vim.keymap.set('n', 'N', 'Nzz', { noremap = true, silent = true }) vim.keymap.set({ 'v', 'i' }, 'wq', 'l', { noremap = true, silent = true }) -vim.keymap.set('n', 'x', '"rd', { remap = true, silent = true }) +vim.keymap.set('v', "<", "", ">gv") + +-- clipboard +vim.keymap.set({ 'n', 'v', 'x' }, 'y', '"+y', { noremap = true, silent = true }) +vim.keymap.set('n', 'yy', '"+yy', { noremap = true, silent = true }) +vim.keymap.set({ 'n', 'v', 'x' }, 'p', '"+p', { noremap = true, silent = true }) + +-- resize splits if window got resized +vim.api.nvim_create_autocmd({ "VimResized" }, { + group = vim.api.nvim_create_augroup("resize_splits", { clear = true }), + callback = function() + local current_tab = vim.fn.tabpagenr() + vim.cmd("tabdo wincmd =") + vim.cmd("tabnext " .. current_tab) + end, +}) + +-- Check if we need to reload the file when it changed +vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { + group = vim.api.nvim_create_augroup("check_reload", { clear = true }), + callback = function() + if vim.o.buftype ~= "nofile" then + vim.cmd("checktime") + end + end, +}) diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index dc4c0b0..5b890bd 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -129,9 +129,6 @@ return { vim.keymap.set('n', 'dh', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP hints toggle' }) - vim.keymap.set('n', 'df', function() - vim.lsp.buf.format { async = true } - end, { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP format' }) -- Auto-refresh code lenses if not client then return @@ -153,16 +150,34 @@ return { end, }, { - 'nvimtools/none-ls.nvim', + 'stevearc/conform.nvim', + event = 'VeryLazy', + opts = { + notify_no_formatters = false, + formatters_by_ft = { + json = { "jq" }, + puppet = { "puppet-lint" }, + ['*'] = { 'trim_whitespace' } + }, + format_on_save = { + timeout_ms = 500, + lsp_format = "last", + }, + }, + }, + { + 'mfussenegger/nvim-lint', event = 'VeryLazy', config = function() - local null = require('null-ls') - null.setup { - sources = { - null.builtins.diagnostics.puppet_lint, - null.builtins.diagnostics.yamllint, - }, + require("lint").linters_by_ft = { + docker = { "hadolint" }, + yaml = { "yamllint" }, + puppet = { "puppet-lint" }, + sh = { "shellcheck" }, + go = { "golangcilint" }, + ruby = { "rubocop" }, } - end, + vim.api.nvim_command('au BufWritePost * lua require("lint").try_lint()') + end }, } diff --git a/nvim/lua/plugins/mini.lua b/nvim/lua/plugins/mini.lua index 5d95310..eb365a0 100644 --- a/nvim/lua/plugins/mini.lua +++ b/nvim/lua/plugins/mini.lua @@ -2,6 +2,7 @@ return { { 'echasnovski/mini.nvim', lazy = false, + dependencies = { "folke/snacks.nvim" }, config = function() require('mini.basics').setup { mappings = { windows = true, }, } require('mini.tabline').setup({ @@ -50,8 +51,6 @@ return { require('mini.jump2d').setup({ mappings = { start_jumping = 'S' } }); require('mini.surround').setup() require('mini.splitjoin').setup { detect = { separator = '[,;\n]' }, } - require('mini.trailspace').setup() - vim.api.nvim_create_user_command('Trim', require('mini.trailspace').trim, {}) local miniclue = require('mini.clue') miniclue.setup { @@ -136,6 +135,12 @@ return { ) end, }) + vim.api.nvim_create_autocmd("User", { + pattern = "MiniFilesActionRename", + callback = function(event) + Snacks.rename.on_rename_file(event.data.from, event.data.to) + end, + }) end) end, }, diff --git a/nvim/lua/plugins/snacks.lua b/nvim/lua/plugins/snacks.lua index f323ea8..a7fd6ee 100644 --- a/nvim/lua/plugins/snacks.lua +++ b/nvim/lua/plugins/snacks.lua @@ -6,6 +6,8 @@ return { priority = 1000, opts = { bigfile = { enabled = true }, + dim = { enabled = true }, + quickfile = { enabled = true }, notifier = { enabled = true }, scope = { enabled = true }, terminal = { enabled = true }, @@ -57,10 +59,11 @@ return { vim.api.nvim_set_hl(0, 'SnacksPickerDir', { fg = '#cccccc' }) end, keys = { - { '', function() Snacks.terminal.toggle() end, mode = { "n", "t" }, noremap = true, desc = 'terminal open' }, - { 't', function() Snacks.terminal.toggle('$SHELL') end, mode = { "n", "t" }, noremap = true, desc = 'terminal open' }, - { 'm', function() Snacks.words.jump(1, true) end, noremap = true, desc = 'next reference' }, - { 'M', function() Snacks.words.jump(-1, true) end, noremap = true, desc = 'next reference' }, + { '', function() Snacks.terminal.toggle() end, mode = { "n", "t" }, noremap = true, desc = 'terminal open' }, + { '\\\\', function() Snacks.terminal.toggle('$SHELL') end, mode = { "n", "t" }, noremap = true, desc = 'terminal open' }, + { 'm', function() Snacks.words.jump(1, true) end, noremap = true, desc = 'next reference' }, + { 'M', function() Snacks.words.jump(-1, true) end, noremap = true, desc = 'next reference' }, + { '\\z', function() Snacks.dim() end, noremap = true, desc = 'dim' }, { 'ff', function() Snacks.picker.smart() end, @@ -68,9 +71,14 @@ return { }, { 'fe', - function() Snacks.picker.explorer() end, + function() Snacks.explorer() end, { noremap = true, silent = true, desc = 'snacks explorer' } }, + { + 'fE', + function() Snacks.explorer.reveal() end, + { noremap = true, silent = true, desc = 'snacks explorer open current file' } + }, { 'fg', function() Snacks.picker.files() end,