# HG changeset patch # User zegervdv # Date 1617809225 -7200 # Node ID 6d1a9a92638345f21458dc28ccc19388965f2aca # Parent 1dfda47d5d9e8468d2f97e697ef2f1926c88f8c6 Restructure mappings diff -r 1dfda47d5d9e -r 6d1a9a926383 dot_config/nvim/config.lua --- a/dot_config/nvim/config.lua Wed Apr 07 17:13:37 2021 +0200 +++ b/dot_config/nvim/config.lua Wed Apr 07 17:27:05 2021 +0200 @@ -14,420 +14,412 @@ end -- Packer configuration is compiled and only needs to be loaded on changes -function packer_enable() - vim.cmd "packadd packer.nvim" +vim.cmd "packadd packer.nvim" - require('packer').startup(function() - use {'wbthomason/packer.nvim', opt = true} +require('packer').startup(function() + use {'wbthomason/packer.nvim', opt = true} - -- General plugins - use {'tpope/vim-sensible'} - use {'tpope/vim-repeat'} - use {'tpope/vim-rsi'} - use {'sgur/vim-editorconfig'} - use {'ShikChen/osc52.vim'} - use {'einfachtoll/didyoumean'} + -- General plugins + use {'tpope/vim-sensible'} + use {'tpope/vim-repeat'} + use {'tpope/vim-rsi'} + use {'sgur/vim-editorconfig'} + use {'ShikChen/osc52.vim'} + use {'einfachtoll/didyoumean'} - use {'tpope/vim-obsession'} - use { - 'tpope/vim-eunuch', - cmd = { - 'Remove', - 'Unlink', - 'Move', - 'Rename', - 'Mkdir', - 'Chmod', - 'Find', - 'Locate', - 'SudoEdit', - 'SudoWrite' - } + use {'tpope/vim-obsession'} + use { + 'tpope/vim-eunuch', + cmd = { + 'Remove', + 'Unlink', + 'Move', + 'Rename', + 'Mkdir', + 'Chmod', + 'Find', + 'Locate', + 'SudoEdit', + 'SudoWrite' } + } - use {'psliwka/vim-smoothie'} + use {'psliwka/vim-smoothie'} + + -- Spelling/autocorrection + use {'tpope/vim-abolish'} - -- Spelling/autocorrection - use {'tpope/vim-abolish'} + -- Git/VCS + use {'vim-scripts/gitignore'} + use {'sjl/splice.vim', opt = true, cmd = {'SpliceInit'}} + use {'tpope/vim-git'} + + -- Comments + use {'tpope/vim-commentary'} - -- Git/VCS - use {'vim-scripts/gitignore'} - use {'sjl/splice.vim', opt = true, cmd = {'SpliceInit'}} - use {'tpope/vim-git'} + -- Undoing + use {'sjl/gundo.vim', cmd = {'GundoToggle'}} - -- Comments - use {'tpope/vim-commentary'} + -- Parentheses etc + use {'tpope/vim-surround'} + use {'raimondi/delimitMate'} - -- Undoing - use {'sjl/gundo.vim', cmd = {'GundoToggle'}} + -- Moving around within lines + use {'wellle/targets.vim', event = 'InsertEnter *'} - -- Parentheses etc - use {'tpope/vim-surround'} - use {'raimondi/delimitMate'} + -- Peek at lines + use { + 'nacro90/numb.nvim', + config = require'numb'.setup, + } - -- Moving around within lines - use {'wellle/targets.vim', event = 'InsertEnter *'} + -- Searching + use {'mhinz/vim-grepper', cmd = {'Grepper'}} - -- Peek at lines - use { - 'nacro90/numb.nvim', - config = require'numb'.setup, - } - - -- Searching - use {'mhinz/vim-grepper', cmd = {'Grepper'}} + -- Keymaps TODO: to be removed when #13823 is merged + use { + 'tjdevries/astronauta.nvim', + config = function() require'astronauta.keymap' end, + } - -- Keymaps TODO: to be removed when #13823 is merged - use { - 'tjdevries/astronauta.nvim', - config = function() require'astronauta.keymap' end, - } + -- Indent lines + use { + 'lukas-reineke/indent-blankline.nvim', + branch = 'lua', + config = function () + vim.g.indent_blankline_buftype_exclude = {'terminal', 'help', 'nofile'} + vim.g.indent_blankline_show_first_indent_level = false + end, + } - -- Indent lines - use { - 'lukas-reineke/indent-blankline.nvim', - branch = 'lua', - config = function () - vim.g.indent_blankline_buftype_exclude = {'terminal', 'help', 'nofile'} - vim.g.indent_blankline_show_first_indent_level = false - end - } + -- Increment/decrement + use { + 'zegervdv/nrpattern.nvim', + requires = 'tpope/vim-repeat', + config = function () + local nrpattern = require"nrpattern" + local defaults = require"nrpattern.default" - -- Increment/decrement - use { - 'zegervdv/nrpattern.nvim', - requires = 'tpope/vim-repeat', - config = function () - local nrpattern = require"nrpattern" - local defaults = require"nrpattern.default" - - defaults[{"input", "output"}] = { - priority = 12, - filetypes = {"verilog", "systemverilog"}, - } - defaults[{"'1", "'0"}] = { - priority = 9, - filetypes = {"verilog", "systemverilog"}, - } + defaults[{"input", "output"}] = { + priority = 12, + filetypes = {"verilog", "systemverilog"}, + } + defaults[{"'1", "'0"}] = { + priority = 9, + filetypes = {"verilog", "systemverilog"}, + } + + nrpattern.setup(defaults) + end, + } - nrpattern.setup(defaults) - end, - } + -- Tmux + function test_tmux() + return os.getenv('TMUX') ~= nil + end + use {'tmux-plugins/vim-tmux-focus-events', cond = test_tmux} + use { + 'numtostr/navigator.nvim', + config = function() + require('Navigator').setup { auto_save = 'current', disable_on_zoom = true } - -- Tmux - function test_tmux() - return os.getenv('TMUX') ~= nil - end - use {'tmux-plugins/vim-tmux-focus-events', cond = test_tmux} - use { - 'numtostr/navigator.nvim', - config = function() - require('Navigator').setup { auto_save = 'current', disable_on_zoom = false } - - local nnoremap = vim.keymap.nnoremap - nnoremap { '', require'Navigator'.left } - nnoremap { '', require'Navigator'.down } - nnoremap { '', require'Navigator'.up } - nnoremap { '', require'Navigator'.right } - end - } + local nnoremap = vim.keymap.nnoremap + nnoremap { '', require'Navigator'.left, silent = true } + nnoremap { '', require'Navigator'.down, silent = true } + nnoremap { '', require'Navigator'.up, silent = true } + nnoremap { '', require'Navigator'.right, silent = true } + end, + } - -- Completion/snippets/LSP - use {'neovim/nvim-lspconfig'} - use { - 'hrsh7th/nvim-compe', - config = function () - require'compe'.setup { - enabled = true; - autocomplete = true; - debug = false; - min_length = 1; - preselect = 'enable'; - throttle_time = 80; - source_timeout = 1000; - incomplete_delay = 400; - max_abbr_width = 100; - max_kind_width = 100; - max_menu_width = 100; - documentation = true; + -- Completion/snippets/LSP + use {'neovim/nvim-lspconfig'} + use { + 'hrsh7th/nvim-compe', + config = function () + require'compe'.setup { + enabled = true; + autocomplete = true; + debug = false; + min_length = 1; + preselect = 'enable'; + throttle_time = 80; + source_timeout = 1000; + incomplete_delay = 400; + max_abbr_width = 100; + max_kind_width = 100; + max_menu_width = 100; + documentation = true; - source = { - path = true; - buffer = true; - nvim_lsp = true; - nvim_lua = true; - spell = true; - ultisnips = true; - -- TODO add vsnip for LSP snippets - }; - } + source = { + path = true; + buffer = true; + nvim_lsp = true; + nvim_lua = true; + spell = true; + ultisnips = true; + -- TODO add vsnip for LSP snippets + }; + } - vim.cmd [[ inoremap compe#complete() ]] - vim.cmd [[ inoremap compe#confirm({ 'keys': "\delimitMateCR", 'mode': '' }) ]] - vim.cmd [[ inoremap compe#close('') ]] - end - } - use { - { - 'nvim-treesitter/nvim-treesitter', - config = function () - require "nvim-treesitter.highlight" + vim.cmd [[ inoremap compe#complete() ]] + vim.cmd [[ inoremap compe#confirm({ 'keys': "\delimitMateCR", 'mode': '' }) ]] + vim.cmd [[ inoremap compe#close('') ]] + end + } + use { + { + 'nvim-treesitter/nvim-treesitter', + config = function () + require "nvim-treesitter.highlight" - require'nvim-treesitter.configs'.setup { - highlight = { - enable = false, - }, - incremental_selection = { + require'nvim-treesitter.configs'.setup { + highlight = { + enable = false, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + } + }, + refactor = { + highlight_definitions = { enable = true }, + smart_rename = { enable = true, keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - } + smart_rename = "gsr", + }, }, - refactor = { - highlight_definitions = { enable = true }, - smart_rename = { - enable = true, - keymaps = { - smart_rename = "gsr", - }, - }, - navigation = { - enable = true, - keymaps = { - goto_definition = "gnd", - list_definitions = "gnD", - }, + navigation = { + enable = true, + keymaps = { + goto_definition = "gnd", + list_definitions = "gnD", }, }, - textobjects = { - move = { - enable = true, - goto_next_start = { - ["]]"] = "@block.outer", - }, - goto_previous_start = { - ["[["] = "@block.outer", - }, - goto_next_end = { - ["]["] = "@block.outer", - }, - goto_previous_end = { - ["[]"] = "@block.outer", - }, + }, + textobjects = { + move = { + enable = true, + goto_next_start = { + ["]]"] = "@block.outer", + }, + goto_previous_start = { + ["[["] = "@block.outer", + }, + goto_next_end = { + ["]["] = "@block.outer", + }, + goto_previous_end = { + ["[]"] = "@block.outer", }, }, - playground = { - enable = true, - disable = {}, - updatetime = 25, - persist_queries = false - } - } - end - }, - 'nvim-treesitter/nvim-treesitter-refactor', - 'nvim-treesitter/nvim-treesitter-textobjects', - {'nvim-treesitter/playground', opt = true}, - } - use {'SirVer/ultisnips'} - use { - 'glepnir/lspsaga.nvim', - config = function() - require 'lspsaga'.init_lsp_saga {} - end - } - use { - 'nvim-telescope/telescope.nvim', - requires = { - 'nvim-lua/popup.nvim', - 'nvim-lua/plenary.nvim' - } - } - - -- Vanity - use { - 'yamatsum/nvim-web-nonicons', - requires = 'kyazdani42/nvim-web-devicons', - config = function() - require'nvim-nonicons' - end - } - - use { - 'glepnir/galaxyline.nvim', - branch = 'main', - -- your statusline - config = function() - local gl = require'galaxyline' - local colors = require('galaxyline.theme').default - local condition = require('galaxyline.condition') - local gls = gl.section - - colors.bg = '#2C323C' - - gls.left[1] = { - RainbowRed = { - provider = function() return '▊ ' end, - highlight = {colors.blue,colors.bg} }, - } - - gls.left[2] = { - FileIcon = { - provider = 'FileIcon', - condition = condition.buffer_not_empty, - highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg}, - }, - } - - gls.left[3] = { - FileName = { - provider = 'FileName', - condition = condition.buffer_not_empty, - highlight = {colors.magenta,colors.bg,'bold'} - } - } - - - gls.left[4] = { - DiagnosticError = { - provider = 'DiagnosticError', - icon = '  ', - highlight = {colors.red,colors.bg} + playground = { + enable = true, + disable = {}, + updatetime = 25, + persist_queries = false } } + end + }, + 'nvim-treesitter/nvim-treesitter-refactor', + 'nvim-treesitter/nvim-treesitter-textobjects', + {'nvim-treesitter/playground', opt = true}, + } + use {'SirVer/ultisnips'} + use { + 'glepnir/lspsaga.nvim', + config = function() + require 'lspsaga'.init_lsp_saga {} + end + } + use { + 'nvim-telescope/telescope.nvim', + requires = { + 'nvim-lua/popup.nvim', + 'nvim-lua/plenary.nvim' + } + } - gls.right[1] = { - ShowLspClient = { - provider = 'GetLspClient', - condition = function () - local tbl = {['dashboard'] = true,['']=true} - if tbl[vim.bo.filetype] then - return false - end - return true - end, - icon = require'nvim-nonicons'.get('server') .. ' LSP:', - highlight = {colors.green,colors.bg,'bold'} - } - } + -- Vanity + use { + 'yamatsum/nvim-web-nonicons', + requires = 'kyazdani42/nvim-web-devicons', + config = function() + require'nvim-nonicons' + end + } - gls.right[2] = { - LineInfo = { - provider = 'LineColumn', - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.fg,colors.bg}, - }, - } + use { + 'glepnir/galaxyline.nvim', + branch = 'main', + -- your statusline + config = function() + local gl = require'galaxyline' + local colors = require('galaxyline.theme').default + local condition = require('galaxyline.condition') + local gls = gl.section + + colors.bg = '#2C323C' - gls.right[3] = { - PerCent = { - provider = 'LinePercent', - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.fg,colors.bg,'bold'}, - } - } - gls.right[8] = { - RainbowBlue = { - provider = function() return ' ▊' end, - highlight = {colors.blue,colors.bg} - }, - } + gls.left[1] = { + RainbowRed = { + provider = function() return '▊ ' end, + highlight = {colors.blue,colors.bg} + }, + } + + gls.left[2] = { + FileIcon = { + provider = 'FileIcon', + condition = condition.buffer_not_empty, + highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color, colors.bg}, + }, + } - gls.short_line_left[1] = { - BufferType = { - provider = 'FileTypeName', - separator = ' ', - separator_highlight = {'NONE',colors.bg}, - highlight = {colors.blue,colors.bg,'bold'} - } + gls.left[3] = { + FileName = { + provider = 'FileName', + condition = condition.buffer_not_empty, + highlight = {colors.magenta,colors.bg,'bold'} + } + } + + + gls.left[4] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = {colors.red,colors.bg} } + } - gls.short_line_left[2] = { - SFileName = { - provider = 'SFileName', - condition = condition.buffer_not_empty, - highlight = {colors.fg,colors.bg,'bold'} - } + gls.right[1] = { + ShowLspClient = { + provider = 'GetLspClient', + condition = function () + local tbl = {['dashboard'] = true,['']=true} + if tbl[vim.bo.filetype] then + return false + end + return true + end, + icon = require'nvim-nonicons'.get('server') .. ' LSP:', + highlight = {colors.green,colors.bg,'bold'} } + } - gls.short_line_right[1] = { - BufferIcon = { - provider= 'BufferIcon', - highlight = {colors.fg,colors.bg} - } - } - end, - } + gls.right[2] = { + LineInfo = { + provider = 'LineColumn', + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.fg,colors.bg}, + }, + } - -- File navigation - use {'justinmk/vim-dirvish'} + gls.right[3] = { + PerCent = { + provider = 'LinePercent', + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.fg,colors.bg,'bold'}, + } + } + gls.right[8] = { + RainbowBlue = { + provider = function() return ' ▊' end, + highlight = {colors.blue,colors.bg} + }, + } - -- Colorscheme - use {'zegervdv/nvcode-color-schemes.vim'} - use { - 'zegervdv/one-lush', - requires = 'rktjmp/lush.nvim', - config = function() - local lush = require('lush') - local spec = require('lush_theme.one-lush') - lush(spec) - end, - } + gls.short_line_left[1] = { + BufferType = { + provider = 'FileTypeName', + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.blue,colors.bg,'bold'} + } + } + + gls.short_line_left[2] = { + SFileName = { + provider = 'SFileName', + condition = condition.buffer_not_empty, + highlight = {colors.fg,colors.bg,'bold'} + } + } - -- Terminal - use { - 'akinsho/nvim-toggleterm.lua', - config = function() - require'toggleterm'.setup { - size = 20, - open_mapping = [[]], - shade_filetypes = {}, - shade_terminals = true, - persist_size = true, - direction = 'horizontal', + gls.short_line_right[1] = { + BufferIcon = { + provider= 'BufferIcon', + highlight = {colors.fg,colors.bg} } - end, - } + } + end, + } + + -- File navigation + use {'justinmk/vim-dirvish'} - -- Filetypes - use {'Glench/Vim-Jinja2-Syntax'} - - end) -end + -- Colorscheme + use {'zegervdv/nvcode-color-schemes.vim'} + use { + 'zegervdv/one-lush', + requires = 'rktjmp/lush.nvim', + config = function() + local lush = require('lush') + local spec = require('lush_theme.one-lush') + lush(spec) + end, + } --- This came from https://github.com/tjdevries/config_manager/blob/master/xdg_config/nvim/lua/lsp_config.lua -local mapper = function(mode, key, result, noremap) - if noremap == nil then - noremap = true - end - vim.api.nvim_buf_set_keymap(0, mode, key, result, {noremap=noremap, silent=true}) -end + -- Terminal + use { + 'akinsho/nvim-toggleterm.lua', + config = function() + require'toggleterm'.setup { + size = 20, + open_mapping = [[]], + shade_filetypes = {}, + shade_terminals = true, + persist_size = true, + direction = 'horizontal', + } + end, + } --- LSP and Treesitter config + -- Filetypes + use {'Glench/Vim-Jinja2-Syntax'} + +end) + +-- LSP config local lsp = require'lspconfig' local lsputil = require'lspconfig.util' local on_attach = function(client) - mapper('n', '', 'lua require"lspsaga.diagnostic".show_line_diagnostics()') - mapper('n', 'gd', 'lua vim.lsp.buf.declaration()') - mapper('n', '', 'lua vim.lsp.buf.definition()') - mapper('n', 'K', 'lua require"lspsaga.hover".render_hover_doc()') - mapper('n', 'gD', 'lua vim.lsp.buf.implementation()') - mapper('n', '1gD', 'lua vim.lsp.buf.type_definition()') - mapper('n', 'gr', "lua vim.lsp.buf.references()") - mapper('n', 'tgr', "lua require'telescope.builtin'.lsp_references()") - mapper('n', 'g0', 'lua vim.lsp.buf.document_symbol()') - mapper('i', '', 'lua vim.lsp.buf.signature_help()') - mapper('n', 'f', 'lua vim.lsp.buf.code_action()') - mapper('n', '', 'lua vim.lsp.buf.formatting()') - mapper("n", "gp", "lua require'lspsaga.provider'.preview_definition()") + local nnoremap = vim.keymap.nnoremap + local inoremap = vim.keymap.inoremap + nnoremap { '', require"lspsaga.diagnostic".show_line_diagnostics, silent = true } + nnoremap { 'gd', vim.lsp.buf.declaration, silent = true } + nnoremap { '', vim.lsp.buf.definition, silent = true } + nnoremap { 'K', require'lspsage.hover'.render_hover_doc, silent = true } + nnoremap { 'gD', vim.lsp.buf.implementation, silent = true } + nnoremap { '1gD', vim.lsp.buf.type_definition, silent = true } + nnoremap { 'gr', vim.lsp.buf.references, silent = true } + nnoremap { 'tgr', require'telescope.builtin'.lsp_references, silent = true } + nnoremap { 'g0', vim.lsp.buf.document_symbol, silent = true } + nnoremap { '', vim.lsp.buf.formatting, silent = true } + nnoremap { 'gp', require'lspsaga.provider'.preview_definition, silent = true } + + inoremap { '', vim.lsp.buf.signature_help, silent = true} end