From 14fec02d6387fd59645aecbc78c3f02acc13bf81 Mon Sep 17 00:00:00 2001 From: iofq Date: Wed, 21 Aug 2024 02:35:12 -0500 Subject: [PATCH] few bugfixes, mini.files --- nix/mkNeovim.nix | 18 +-- nix/neovim-overlay.nix | 3 +- nvim/init.lua | 19 ++-- nvim/lua/config/init.lua | 7 +- nvim/lua/plugins/lsp.lua | 8 +- nvim/lua/plugins/mini.lua | 189 ++++++++++++++++---------------- nvim/lua/plugins/misc.lua | 56 +++------- nvim/lua/plugins/telescope.lua | 1 - nvim/lua/plugins/treesitter.lua | 2 +- 9 files changed, 145 insertions(+), 158 deletions(-) diff --git a/nix/mkNeovim.nix b/nix/mkNeovim.nix index 289c987..e71663a 100644 --- a/nix/mkNeovim.nix +++ b/nix/mkNeovim.nix @@ -105,22 +105,26 @@ with lib; # and prepends the nvim and after directory to the RTP initLua = '' vim.opt.rtp:prepend('${nvimRtp}/lua') - lazy_opts = { + LAZY_OPTS = { performance = { reset_packpath = false, - rtp = { reset = false, }, + rtp = { + reset = false, + disabled_plugins = { + "netrwPlugin", + "tutor", + }, + }, }, dev = { path = "${pkgs.neovimUtils.packDir neovimConfig.packpathDirs}/pack/myNeovimPackages/start", patterns = {""}, }, + checker = { + enabled = false, + }, install = { missing = false, }, spec = {{ import = "plugins" }}, - disabled_plugins = { - "netrwPlugin", - "tutor", - "zipPlugin", - }, } '' + (builtins.readFile ../nvim/init.lua); diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 84f2153..8e8f382 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -43,6 +43,7 @@ with final.pkgs.lib; let nvim-lspconfig nvim-neoclip-lua nvim-nio + nvim-autopairs nvim-treesitter-context nvim-treesitter-textobjects (nvim-treesitter.withPlugins(p: with p; [ @@ -72,8 +73,6 @@ with final.pkgs.lib; let tree-sitter-typescript tree-sitter-yaml ])) - nvim-web-devicons - oil-nvim outline-nvim scope-nvim snipe-nvim diff --git a/nvim/init.lua b/nvim/init.lua index cb810f8..215be02 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,6 +1,6 @@ vim.g.mapleader = ' ' -- If lazy_opts is set, we're running in wrapped neovim via nix -if not lazy_opts then +if not LAZY_OPTS then -- Bootstrapping lazy.nvim local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then @@ -14,14 +14,19 @@ if not lazy_opts then } end vim.opt.rtp:prepend(lazypath) - lazy_opts = { + LAZY_OPTS = { spec = { { import = 'plugins' } }, - disabled_plugins = { - 'netrwPlugin', - 'tutor', - 'zipPlugin', + performance = { + reset_packpath = false, + rtp = { + reset = false, + disabled_plugins = { + "netrwPlugin", + "tutor", + }, + }, }, } end -require('lazy').setup(lazy_opts) +require('lazy').setup(LAZY_OPTS) require('config') diff --git a/nvim/lua/config/init.lua b/nvim/lua/config/init.lua index 58ca894..87bd5a4 100644 --- a/nvim/lua/config/init.lua +++ b/nvim/lua/config/init.lua @@ -10,7 +10,7 @@ vim.opt.relativenumber = true vim.opt.shadafile = 'NONE' -- disable shada vim.opt.shiftwidth = 0 -- >> shifts by tabstop vim.opt.showmatch = true -- highlight matching brackets -vim.opt.showmode = true +vim.opt.showmode = false vim.opt.signcolumn = 'no' vim.opt.spell = false vim.opt.softtabstop = -1 -- backspace removes tabstop @@ -84,7 +84,10 @@ vim.diagnostic.config { -- random keymaps vim.keymap.set('n', 'gq', vim.cmd.bdelete, { silent = true }) -vim.keymap.set('n', 'gr', 'gT', { noremap = true, 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 }) +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 }) diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index cd5f603..a4293e1 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -28,7 +28,7 @@ return { }, { 'neovim/nvim-lspconfig', - event = 'VeryLazy', + lazy = false, dependencies = { 'hrsh7th/cmp-nvim-lsp', }, @@ -39,7 +39,7 @@ return { lspconfig.util.default_config.capabilities, require('cmp_nvim_lsp').default_capabilities() ) - + vim.lsp.inlay_hint.enable(true) lspconfig.gopls.setup { settings = { gopls = { @@ -91,15 +91,12 @@ return { Lua = {}, }, } - vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Prev diagnostic' }) - vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Next diagnostic' }) vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('UserLspConfig', {}), callback = function(ev) local bufnr = ev.buf local client = vim.lsp.get_client_by_id(ev.data.client_id) - require('workspace-diagnostics').populate_workspace_diagnostics(client, bufnr) vim.keymap.set( 'n', 'K', @@ -175,6 +172,7 @@ return { }) vim.lsp.codelens.refresh { bufnr = bufnr } end + require('workspace-diagnostics').populate_workspace_diagnostics(client, bufnr) end, }) vim.api.nvim_exec_autocmds('FileType', {}) diff --git a/nvim/lua/plugins/mini.lua b/nvim/lua/plugins/mini.lua index 78be31d..4472aa0 100644 --- a/nvim/lua/plugins/mini.lua +++ b/nvim/lua/plugins/mini.lua @@ -3,9 +3,10 @@ return { 'echasnovski/mini.nvim', lazy = false, config = function() - require('mini.ai').setup() - require('mini.comment').setup() - require('mini.pairs').setup() + require('mini.tabline').setup({ + tabpage_section = 'right', + show_icons = false, + }) require('mini.statusline').setup { content = { active = function() @@ -50,103 +51,103 @@ return { end, }, } - vim.opt.showmode = false + vim.schedule(function() + require('mini.ai').setup() + require('mini.align').setup() + require('mini.bracketed').setup() + require('mini.comment').setup() + require('mini.icons').setup() + require('mini.surround').setup() + require('mini.jump2d').setup { mappings = { start_jumping = 'S' } } + require('mini.splitjoin').setup { detect = { separator = '[,;\n]' }, } + require('mini.basics').setup { mappings = { windows = true, }, } + require('mini.trailspace').setup() + vim.api.nvim_create_user_command('Trim', function() + require('mini.trailspace').trim() + end, {}) + local indent = require('mini.indentscope') + indent.setup { + draw = { delay = 0 }, + } + indent.gen_animation.none() - local miniclue = require('mini.clue') - miniclue.setup { - triggers = { - { mode = 'n', keys = '' }, - { mode = 'n', keys = 'g' }, - { mode = 'n', keys = "'" }, - { mode = 'n', keys = '`' }, - { mode = 'n', keys = '"' }, - { mode = 'n', keys = '' }, - { mode = 'n', keys = 'z' }, - }, - - clues = { - miniclue.gen_clues.g(), - miniclue.gen_clues.marks(), - miniclue.gen_clues.registers(), - miniclue.gen_clues.windows(), - miniclue.gen_clues.z(), - }, - } - -- Add surrounding with sa - -- Delete surrounding with sd. - -- Replace surrounding with sr. - -- Find surrounding with sf or sF (move cursor right or left). - -- Highlight surrounding with sh. - -- 'f' - function call (string of alphanumeric symbols or '_' or '.' followed by balanced '()'). In "input" finds function call, in "output" prompts user to enter function name. - -- 't' - tag. In "input" finds tag with same identifier, in "output" prompts user to enter tag name. - -- All symbols in brackets '()', '[]', '{}', '<>". - -- '?' - interactive. Prompts user to enter left and right parts. - require('mini.surround').setup() - - require('mini.trailspace').setup() - vim.api.nvim_create_user_command('Trim', function() - require('mini.trailspace').trim() - end, {}) - - -- prefix \ - -- `b` - |'background'|. - -- `c` - |'cursorline'|. - -- `C` - |'cursorcolumn'|. - -- `d` - diagnostic (via |vim.diagnostic.enable()| and |vim.diagnostic.disable()|). - -- `h` - |'hlsearch'| (or |v:hlsearch| to be precise). - -- `i` - |'ignorecase'|. - -- `l` - |'list'|. - -- `n` - |'number'|. - -- `r` - |'relativenumber'|. - -- `s` - |'spell'|. - -- `w` - |'wrap'|. - require('mini.basics').setup { - mappings = { - windows = true, - }, - } + local miniclue = require('mini.clue') + miniclue.setup { + triggers = { + { mode = 'n', keys = '' }, + { mode = 'n', keys = 'g' }, + { mode = 'n', keys = "'" }, + { mode = 'n', keys = '`' }, + { mode = 'n', keys = '"' }, + { mode = 'n', keys = '' }, + { mode = 'n', keys = 'z' }, + }, - local map = require('mini.map') - map.setup { - symbols = { - scroll_line = '┃', - scroll_view = '', - }, - integrations = { - map.gen_integration.builtin_search(), - map.gen_integration.diagnostic(), - map.gen_integration.gitsigns(), - }, - window = { - show_integration_count = false, - winblend = 0, - width = 5, - }, - } - vim.keymap.set('n', 'nm', map.toggle, { noremap = true, desc = 'minimap open' }) + clues = { + miniclue.gen_clues.g(), + miniclue.gen_clues.marks(), + miniclue.gen_clues.registers(), + miniclue.gen_clues.windows(), + miniclue.gen_clues.z(), + }, + } - -- gS - require('mini.splitjoin').setup { - detect = { separator = '[,;\n]' }, - } - require('mini.jump2d').setup { mappings = { start_jumping = 'S' } } - local indent = require('mini.indentscope') - indent.setup { - draw = { delay = 0 }, - } - indent.gen_animation.none() + local map = require('mini.map') + map.setup { + symbols = { + scroll_line = '┃', + scroll_view = '', + }, + integrations = { + map.gen_integration.builtin_search(), + map.gen_integration.diagnostic(), + map.gen_integration.gitsigns(), + }, + window = { + show_integration_count = false, + winblend = 0, + width = 5, + }, + } + vim.keymap.set('n', 'nm', map.toggle, { noremap = true, desc = 'minimap open' }) - require('mini.notify').setup { - window = { - winblend = 0, - config = { - anchor = 'SE', - border = 'double', - row = vim.o.lines, + require('mini.notify').setup { + window = { + winblend = 0, + config = { + border = 'double', + }, }, - }, - } + } + local files = require("mini.files") + files.setup { + mappings = { + synchronize = "w", + go_in_plus="" + }, + windows = { + preview = true, + width_preview = 50, + } + } + vim.keymap.set('n', 'c', files.open, { noremap = true, desc = 'minifiles open' }) + vim.api.nvim_create_autocmd("User", { + pattern = "MiniFilesBufferCreate", + callback = function(args) + local buf_id = args.data.buf_id + vim.keymap.set( + "n", + "c", + function() + files.synchronize() + files.close() + end, + { buffer = buf_id } + ) + end, + }) + end) end, }, } diff --git a/nvim/lua/plugins/misc.lua b/nvim/lua/plugins/misc.lua index 539b3df..de9d412 100644 --- a/nvim/lua/plugins/misc.lua +++ b/nvim/lua/plugins/misc.lua @@ -1,4 +1,9 @@ return { + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + }, { 'danymat/neogen', event = 'VeryLazy', @@ -27,7 +32,6 @@ return { event = 'VeryLazy', dependencies = { "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons" } }, { 'tiagovla/scope.nvim', event = 'VeryLazy', config = true }, @@ -59,9 +63,6 @@ return { 'leath-dub/snipe.nvim', event = 'VeryLazy', opts = { - ui = { - position = 'center', - }, sort = 'last', }, config = function(_, opts) @@ -108,31 +109,6 @@ return { }, }, }, - { - 'stevearc/oil.nvim', - opts = { - watch_for_changes = true, - columns = { - 'permissions', - 'size', - }, - view_options = { - show_hidden = true, - }, - keymaps = { - ['wq'] = 'actions.close', - }, - }, - keys = { - { - 'nc', - function() - require('oil').toggle_float() - end, - { noremap = true, silent = true }, - }, - }, - }, { 'mbbill/undotree', event = 'VeryLazy', @@ -157,16 +133,18 @@ return { config = function(_, opts) require('nightfox').setup(opts) vim.cmd('colorscheme terafox') - vim.api.nvim_set_hl(0, 'MiniNotifyNormal', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniNotifyTitle', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniNotifyBorder', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniMapNormal', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'MiniClueNormal', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'StatusLine', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'StatusLineNC', { bg = 'none' }) - vim.api.nvim_set_hl(0, 'GitSignsAdd', { fg = 'green', bold = true }) - vim.api.nvim_set_hl(0, 'GitSignsDelete', { fg = 'red', bold = true }) - vim.api.nvim_set_hl(0, 'GitSignsChange', { fg = 'green', bold = true }) + vim.schedule(function() + vim.api.nvim_set_hl(0, 'MiniNotifyNormal', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'MiniNotifyTitle', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'MiniNotifyBorder', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'MiniMapNormal', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'MiniClueNormal', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'StatusLine', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'StatusLineNC', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'GitSignsAdd', { fg = 'green', bold = true }) + vim.api.nvim_set_hl(0, 'GitSignsDelete', { fg = 'red', bold = true }) + vim.api.nvim_set_hl(0, 'GitSignsChange', { fg = 'green', bold = true }) + end) end, }, { diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 80d56ce..7fe925e 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -10,7 +10,6 @@ return { dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope-fzf-native.nvim', - 'nvim-tree/nvim-web-devicons', 'nvim-treesitter/nvim-treesitter', 'tiagovla/scope.nvim', }, diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 625df5d..44c53e5 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -1,7 +1,7 @@ return { { 'nvim-treesitter/nvim-treesitter', - lazy = false, + event = 'VeryLazy', dependencies = { 'nvim-treesitter/nvim-treesitter-context', 'nvim-treesitter/nvim-treesitter-textobjects',