neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim.git
Log | Files | Refs

commit 411dc10d1ab952ea740f09fe67c98ad3cecb3c3c
parent d28d9fb5c57d22ca01eb2c8c1b3706a5afd302f5
Author: Tomas Nemec <nemi@skaut.cz>
Date:   Tue, 23 Nov 2021 15:26:56 +0100

update

Diffstat:
Minit.lua | 7+++----
Mlua/my-default.lua | 2+-
Mlua/tms/lsp/init.lua | 1+
Alua/tms/p/aerial.lua | 18++++++++++++++++++
Mlua/tms/p/cmp/exe_source.lua | 3+--
Mlua/tms/p/cmp/init.lua | 30++++++++++++++++--------------
Mlua/tms/p/dap.lua | 18++++++++----------
Mlua/tms/p/gitsigns.lua | 12++----------
Mlua/tms/p/luasnip.lua | 18+++++++++++-------
Alua/tms/p/notify/init.lua | 7+++++++
Dlua/tms/p/notify/my_stage.lua | 30------------------------------
Mlua/tms/p/refactoring.lua | 8++++----
Mlua/tms/p/telescope.lua | 1+
Mlua/tms/plugins.lua | 46+++++++++++++++++++++-------------------------
Mlua/tms/u/reload.lua | 1+
Mlua/tms/u/ui.lua | 6+++---
Mlua/tms/ws/file_pairs.lua | 22+++++++++++++++++++++-
17 files changed, 119 insertions(+), 111 deletions(-)

diff --git a/init.lua b/init.lua @@ -8,6 +8,7 @@ end vim.cmd [[runtime plugin/astronauta.vim]] require('impatient') vim.g.mapleader = ',' +require('colorbuddy').colorscheme('my-default') -- disable netrw vim.g.loaded_netrw = true @@ -68,10 +69,6 @@ else require('packer_compiled') end --- Colorscheme -vim.cmd('syntax enable') -require('colorbuddy').colorscheme('my-default') - -- MAPPINGS local nmap = vim.keymap.nmap local nnoremap = vim.keymap.nnoremap @@ -100,6 +97,8 @@ nnoremap {'<leader>q', '<cmd>quit<cr>'} nnoremap {'<leader>Q', '<cmd>qall<cr>'} nnoremap {'<leader>M', '<cmd>messages<cr>'} nnoremap {'<leader>so', '<cmd>source<cr>'} +nnoremap {'<leader>o', '<cmd>BufOnly<cr>'} +nnoremap {'<leader>O', '<cmd>BufOnly!<cr>'} -- window movement nnoremap {'<a-h>', '<c-w>h'} nnoremap {'<a-j>', '<c-w>j'} diff --git a/lua/my-default.lua b/lua/my-default.lua @@ -68,7 +68,7 @@ Group.new('TabLineSel', colors.c0, colors.c4) Group.new('TermCursorNC', colors.c0, colors.c3) Group.new('VertSplit', colors.c0, colors.c8) Group.new('Title', colors.c4, colors.none, styles.bold) -Group.new('CursorLine', colors.none, dimm(N.bg, 0.01)) +Group.new('CursorLine', colors.none, dimm(N.bg, 0.03)) Group.new('LineNr', colors.c8, colors.none) Group.new('CursorLineNr', colors.c8, colors.none) Group.new('helpLeadBlank', colors.c7, colors.none) diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua @@ -37,6 +37,7 @@ local custom_attach = function(client, bufnr) local lsp = vim.lsp lsp.handlers['textDocument/hover'] = lsp.with(lsp.handlers.hover, {border = 'single'}) lsp.handlers['textDocument/signatureHelp'] = lsp.with(lsp.handlers.signature_help, {border = 'single'}) + require('aerial').on_attach(client, bufnr) keybind(bufnr) end diff --git a/lua/tms/p/aerial.lua b/lua/tms/p/aerial.lua @@ -0,0 +1,18 @@ +local M = {} + +M.setup = function() + vim.g.aerial = {highlight_on_jump = 0} + + local aerial = require('aerial') + aerial.register_attach_cb(function(bufnr) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>r', '<cmd>AerialToggle!<CR>', {}) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '(', '<cmd>AerialPrev<CR>', {}) + vim.api.nvim_buf_set_keymap(bufnr, 'n', ')', '<cmd>AerialNext<CR>', {}) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', ']]', '<cmd>AerialPrevUp<CR>', {}) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', '[[', '<cmd>AerialNextUp<CR>', {}) + end) + + require('telescope').load_extension('aerial') +end + +return M diff --git a/lua/tms/p/cmp/exe_source.lua b/lua/tms/p/cmp/exe_source.lua @@ -1,8 +1,7 @@ -local job = require('plenary.job') - local source = {} local get_files = function(callback) + local job = require('plenary.job') job:new({ command = 'zsh', args = {'-o', 'shwordsplit', '-c', 'IFS=: && stest -flx $PATH'}, diff --git a/lua/tms/p/cmp/init.lua b/lua/tms/p/cmp/init.lua @@ -1,24 +1,23 @@ -local luasnip = require('luasnip') -local cmp = require('cmp') - local M = {} -local register_sources = function() cmp.register_source('exe', require('tms.p.cmp.exe_source').new()) end +local register_sources = function() require('cmp').register_source('exe', require('tms.p.cmp.exe_source').new()) end M.setup = function() register_sources() + local cmp = require('cmp') cmp.setup({ completion = {autocomplete = false}, documentation = {border = 'single'}, - snippet = {expand = function(args) luasnip.lsp_expand(args.body) end}, + snippet = {expand = function(args) require('luasnip').lsp_expand(args.body) end}, mapping = { - ['<C-Space>'] = cmp.mapping.complete(), + ['<C-Space>'] = cmp.mapping.complete({reason = cmp.ContextReason.Auto}), ['<C-d>'] = cmp.mapping.scroll_docs(-4), ['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-e>'] = cmp.mapping.close(), - ['<C-y>'] = cmp.mapping.confirm({select = true}), - ['<CR>'] = cmp.mapping.confirm({select = true}), + ['<C-y>'] = cmp.mapping.confirm({behavior = cmp.ConfirmBehavior.Replace, select = true}), + ['<C-o>'] = cmp.mapping.confirm({behavior = cmp.ConfirmBehavior.Replace, select = true}), + ['<CR>'] = cmp.mapping.confirm({behavior = cmp.ConfirmBehavior.Replace, select = true}), ['<Left>'] = cmp.mapping.close(), ['<Down>'] = cmp.mapping.select_next_item(), ['<Up>'] = cmp.mapping.select_prev_item(), @@ -39,16 +38,19 @@ M.setup = function() }) -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline('/', {completion = {autocomplete = {cmp.TriggerEvent.TextChanged}}, sources = {{name = 'buffer'}}}) + -- cmp.setup.cmdline('/', {completion = {autocomplete = {cmp.TriggerEvent.TextChanged}}, sources = {{name = 'buffer'}}}) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(':', { - completion = {autocomplete = {cmp.TriggerEvent.TextChanged}}, - sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}}), - }) + -- cmp.setup.cmdline(':', { + -- completion = {autocomplete = {cmp.TriggerEvent.TextChanged}}, + -- sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}}), + -- }) end -M.enable_autocomplete = function() cmp.setup.buffer {completion = {autocomplete = {cmp.TriggerEvent.TextChanged}}} end +M.enable_autocomplete = function() + local cmp = require('cmp') + cmp.setup.buffer {completion = {autocomplete = {cmp.TriggerEvent.TextChanged}}} +end return M diff --git a/lua/tms/p/dap.lua b/lua/tms/p/dap.lua @@ -1,8 +1,6 @@ -local dap = require('dap') -local dapui = require('dapui') local M = {} -local function cpp() +local cpp = function(dap) dap.adapters.cpp = { type = 'executable', attach = {pidProperty = 'pid', pidSelect = 'ask'}, @@ -14,7 +12,7 @@ local function cpp() dap.configurations.cpp = {{type = 'cpp', request = 'launch', name = 'Launch File', program = '${file}'}} end -local function dart() +local dart = function(dap) dap.defaults.fallback.external_terminal = {command = '/usr/bin/alacritty', args = {'-e'}} dap.adapters.dart = { @@ -36,7 +34,7 @@ local function dart() } end -local function lua() +local function lua(dap) dap.configurations.lua = { { type = 'nlua', @@ -59,13 +57,13 @@ local function lua() end function M.setup() - -- cpp() - -- dart() - lua() - + local dap = require('dap') + -- cpp(dap) + -- dart(dap) + lua(dap) require('nvim-dap-virtual-text').setup(); end -function M.setup_ui() dapui.setup() end +function M.setup_ui() require('dapui').setup() end return M diff --git a/lua/tms/p/gitsigns.lua b/lua/tms/p/gitsigns.lua @@ -1,18 +1,10 @@ local M = {} local get_theme = function() - local dark_theme = { - add = '│', - change = '│', - delete = '│', - topdelete = '‾', - changedel = '│', - } + local dark_theme = {add = '│', change = '│', delete = '│', topdelete = '‾', changedel = '│'} local light_theme = {add = ' ', change = ' ', delete = ' ', topdelete = ' ', changedel = ' '} local theme = dark_theme - if vim.opt.background:get() == 'light' then - theme = light_theme - end + if vim.opt.background:get() == 'light' then theme = light_theme end return theme end diff --git a/lua/tms/p/luasnip.lua b/lua/tms/p/luasnip.lua @@ -1,8 +1,7 @@ -local luasnip = require('luasnip') - +---@diagnostic disable: unused-local, unused-function local M = {} -local keymaps = function() +local keymaps = function(luasnip) vim.keymap.inoremap {'<C-l>', function() if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() end end} vim.keymap.snoremap {'<C-l>', function() if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() end end} vim.keymap.inoremap {'<C-h>', function() if luasnip.jumpable(-1) then luasnip.jump(-1) end end} @@ -31,7 +30,7 @@ local function bash(_, _, command) return res end -local snippets = function() +local snippets = function(luasnip) local ls = luasnip local s = ls.snippet local sn = ls.snippet_node @@ -59,18 +58,23 @@ local snippets = function() }), }, html = {s('ni', fmt('*ngIf="{1}"', {i(1)}))}, + lua = { + s('fn', fmt('function() {1} end', {i(1)})), + s('r', fmt('require(\'{1}\')', {i(1)})), + s('l', fmt('local {1} = {2}', {i(1), i(2)})), + }, } end --- TODO(tms) 03.11.2021: M.setup = function() + local luasnip = require('luasnip') local types = require('luasnip.util.types') luasnip.config.set_config({ store_selection_keys = '<Tab>', ext_opts = {[types.choiceNode] = {active = {virt_text = {{'choiceNode', 'Comment'}}}}}, }) - keymaps() - snippets() + keymaps(luasnip) + snippets(luasnip) end return M diff --git a/lua/tms/p/notify/init.lua b/lua/tms/p/notify/init.lua @@ -0,0 +1,7 @@ +local M = {} + +M.setup = function() + require('notify').setup({on_open = function(win) vim.api.nvim_win_set_config(win, {focusable = false}) end}) +end + +return M diff --git a/lua/tms/p/notify/my_stage.lua b/lua/tms/p/notify/my_stage.lua @@ -1,30 +0,0 @@ -local stages_util = require('notify.stages.util') - -return { - function(state) - local next_height = state.message.height + 2 - local next_row = stages_util.available_row(state.open_windows, next_height) - if not next_row then return nil end - return { - relative = 'editor', - anchor = 'SE', - width = state.message.width, - height = state.message.height, - col = vim.opt.columns:get(), - row = next_row, - border = 'rounded', - style = 'minimal', - opacity = 0, - focusable = false, - } - end, - function() return {opacity = {100}, col = {vim.opt.columns:get()}} end, - function() return {col = {vim.opt.columns:get()}, time = true} end, - function() - return { - width = {1, frequency = 2.5, damping = 0.9, complete = function(cur_width) return cur_width < 3 end}, - opacity = {0, frequency = 2, complete = function(cur_opacity) return cur_opacity <= 4 end}, - col = {vim.opt.columns:get()}, - } - end, -} diff --git a/lua/tms/p/refactoring.lua b/lua/tms/p/refactoring.lua @@ -1,8 +1,8 @@ -local refactor = require('refactoring') local M = {} -M.setup = function() - refactor.setup() +M.setup = function() + local refactor = require('refactoring') + refactor.setup({}) vim.keymap.vnoremap { '<leader>re', [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]], @@ -13,7 +13,7 @@ M.setup = function() [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]], silent = true, } - vim.keymap.vnoremap { + vim.keymap.nnoremap { '<leader>rv', [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Variable')<CR>]], silent = true, diff --git a/lua/tms/p/telescope.lua b/lua/tms/p/telescope.lua @@ -143,6 +143,7 @@ M.reloader = function() builtin.reloader(layouts.dd_noprev) end M.buffers = function() builtin.buffers(layouts.dd_large) end M.snippets = function() extensions.snippets.snippets(layouts.dd_large) end M.media_files = function() extensions.media_files.media_files() end +M.aerial = function() extensions.aerial.aerial(layouts.dd_large) end M.keymaps = function() builtin.keymaps(layouts.dd_large) end M.quickfix = function() builtin.quickfix(layouts.dd_large_noprev) end M.lsp_code_actions = function() builtin.lsp_code_actions(layouts.dd) end diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua @@ -34,11 +34,7 @@ return packer.startup({ 'numToStr/Comment.nvim', config = function() require('Comment').setup({ - pre_hook = function(_) - local aaa = require('ts_context_commentstring.internal').calculate_commentstring() - dump(aaa) - return aaa - end, + pre_hook = function(_) return require('ts_context_commentstring.internal').calculate_commentstring() end, }) end, } @@ -87,6 +83,14 @@ return packer.startup({ vim.keymap.nmap {'#', '#:Beacon<cr>'} end, } + use { + disable = true, + 'VonHeikemen/fine-cmdline.nvim', + requires = {'MunifTanjim/nui.nvim'}, + config = function() + vim.api.nvim_set_keymap('n', ':', '<cmd>lua require("fine-cmdline").open()<CR>', {noremap = true}) + end, + } -- Nice thing... not sure if i like this vim.g.loaded_matchparen = 1 vim.g.hiPairs_timeout = 5 @@ -158,19 +162,19 @@ return packer.startup({ vim.keymap.xmap {'ia', '<Plug>SidewaysArgumentTextobjI'} vim.keymap.nmap {'<leader>ah', '<Plug>SidewaysArgumentInsertBefore'} vim.keymap.nmap {'<leader>al', '<Plug>SidewaysArgumentAppendAfter'} - vim.keymap.nmap {'<leader>aH', '<Plug>SidewaysArgumentInsertFirt'} + vim.keymap.nmap {'<leader>aH', '<Plug>SidewaysArgumentInsertFirst'} vim.keymap.nmap {'<leader>aL', '<Plug>SidewaysArgumentAppendLast'} end, } use { -- aligning 'godlygeek/tabular', config = function() - vim.keymap.nmap {'<leader>a=', '<cmd>Tabularize /=<cr>'} - vim.keymap.vmap {'<leader>a=', '<cmd>Tabularize /=<cr>'} - vim.keymap.nmap {'<leader>a:', '<cmd>Tabularize /:\\zs<cr>'} - vim.keymap.vmap {'<leader>a:', '<cmd>Tabularize /:\\zs<cr>'} - vim.keymap.nmap {'<leader>a,', '<cmd>Tabularize /,<cr>'} - vim.keymap.vmap {'<leader>a,', '<cmd>Tabularize /,<cr>'} + -- vim.keymap.nmap {'<leader>a=', '<cmd>Tabularize /=<cr>'} + -- vim.keymap.vmap {'<leader>a=', '<cmd>Tabularize /=<cr>'} + -- vim.keymap.nmap {'<leader>a:', '<cmd>Tabularize /:\\zs<cr>'} + -- vim.keymap.vmap {'<leader>a:', '<cmd>Tabularize /:\\zs<cr>'} + -- vim.keymap.nmap {'<leader>a,', '<cmd>Tabularize /,<cr>'} + -- vim.keymap.vmap {'<leader>a,', '<cmd>Tabularize /,<cr>'} end, } use { -- replace @@ -247,14 +251,6 @@ return packer.startup({ } -- colorscheme - -- use {'ishan9299/nvim-solarized-lua', config = function() end} - -- use { - -- 'morhetz/gruvbox', - -- config = function() - -- vim.g.gruvbox_contrast_dark = 'hard' - -- vim.g.gruvbox_contrast_light = 'soft' - -- end, - -- } use {'tjdevries/colorbuddy.nvim'} -- http @@ -264,9 +260,6 @@ return packer.startup({ requires = {'nvim-lua/plenary.nvim'}, config = function() require('rest-nvim').setup() - -- - `<Plug>RestNvim`, run the request under the cursor - -- - `<Plug>RestNvimPreview`, preview the request cURL command - -- - `<Plug>RestNvimLast`, re-run the last request vim.cmd [[command! Rest :lua require("rest-nvim").run()]] vim.cmd [[command! RestPreview :lua require("rest-nvim").run(true)]] vim.cmd [[command! RestLast :lua require("rest-nvim").last()]] @@ -316,14 +309,14 @@ return packer.startup({ 'rcarriga/nvim-notify', config = function() -- vim.notify = require('notify') - require('notify').setup({stages = require('tms.p.notify.my_stage')}) + require('tms.p.notify').setup() vim.keymap.nnoremap {'<leader>N', require('notify').dismiss} end, } -- refactor use { - -- '/home/tms/dev/nvim/refactoring.nvim', + disable = true, 'ThePrimeagen/refactoring.nvim', requires = {'nvim-lua/plenary.nvim', 'nvim-treesitter/nvim-treesitter'}, config = function() require('tms.p.refactoring').setup() end, @@ -331,6 +324,7 @@ return packer.startup({ -- lsp use 'neovim/nvim-lspconfig' + use 'ii14/lsp-command' use 'williamboman/nvim-lsp-installer' use { 'folke/lsp-trouble.nvim', @@ -347,6 +341,7 @@ return packer.startup({ end, requires = {'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig'}, } + use {'stevearc/aerial.nvim', config = function() require('tms.p.aerial').setup() end} -- use 'mfussenegger/nvim-jdtls' -- dap @@ -414,6 +409,7 @@ return packer.startup({ -- extensions vim.keymap.nnoremap {'<space>s', telescope.snippets} vim.keymap.nnoremap {'<space>M', telescope.media_files} + vim.keymap.nnoremap {'<space>r', telescope.aerial} -- custom vim.keymap.nnoremap {'<space>n', telescope.edit_neovim} -- maybe - almost unsuedtelescope diff --git a/lua/tms/u/reload.lua b/lua/tms/u/reload.lua @@ -6,6 +6,7 @@ M.colors = function() package.loaded['colors'] = nil package.loaded['my-default'] = nil require('my-default') + require('colorbuddy').colorscheme('my-default') end return M diff --git a/lua/tms/u/ui.lua b/lua/tms/u/ui.lua @@ -1,11 +1,11 @@ -- local api = vim.api -- local Popup = require('nui.popup') -local Input = require('nui.input') -local event = require('nui.utils.autocmd').event - local M = {} M.input = function(headline, callback) + local Input = require('nui.input') + local event = require('nui.utils.autocmd').event + local input = Input({ border = {style = 'rounded', text = {top = headline, top_align = 'left'}}, relative = 'editor', diff --git a/lua/tms/ws/file_pairs.lua b/lua/tms/ws/file_pairs.lua @@ -2,6 +2,8 @@ local M = {} local ft_letter = {html = 't', scss = 's', dart = 'd', css = 'c'} +local letter_set = {} + local set_mark = function(letter, path, buffer) path = path or vim.fn.expand('%') if buffer == nil then buffer = true end @@ -10,7 +12,22 @@ local set_mark = function(letter, path, buffer) vim.keymap.nnoremap {'<leader>mx' .. letter, '<cmd>split ' .. path .. '<cr>', ['buffer'] = buffer} end +local unset_marks = function() + local leader = vim.g.mapleader + for _, map in ipairs(vim.api.nvim_buf_get_keymap(0, 'n')) do + for _, letter in pairs(ft_letter) do + if map.lhs == leader .. 'm' .. letter then + vim.api.nvim_buf_del_keymap(0, 'n', '<leader>m' .. letter) + end + if map.lhs == leader .. 'mv' .. letter then vim.api.nvim_buf_del_keymap(0, 'n', '<leader>mv' .. letter) end + if map.lhs == leader .. 'mx' .. letter then vim.api.nvim_buf_del_keymap(0, 'n', '<leader>mx' .. letter) end + end + end +end + M.config = function() + -- TODO(tms) 19.11.21: + unset_marks() local filename = vim.fn.expand('%:t:r') local dir = vim.fn.expand('%:h') local files = {} @@ -27,7 +44,10 @@ M.config = function() if event == 'exit' then for ext, file in pairs(files) do local letter = ft_letter[ext] - if letter then set_mark(letter, file, true) end + if letter then + set_mark(letter, file, true) + table.insert(letter_set, letter) + end end files = {} end