diff --git a/home/.config/nvim/after/ftplugin/markdown.vim b/home/.config/nvim/after/ftplugin/markdown.vim index 3b1df70..b39525b 100644 --- a/home/.config/nvim/after/ftplugin/markdown.vim +++ b/home/.config/nvim/after/ftplugin/markdown.vim @@ -1,3 +1,3 @@ -setlocal spell +" setlocal spell setlocal wrap -" setlocal nonumber norelativenumber +setlocal nonumber norelativenumber diff --git a/home/.config/nvim/after/ftplugin/tex.vim b/home/.config/nvim/after/ftplugin/tex.vim index 3b1df70..b39525b 100644 --- a/home/.config/nvim/after/ftplugin/tex.vim +++ b/home/.config/nvim/after/ftplugin/tex.vim @@ -1,3 +1,3 @@ -setlocal spell +" setlocal spell setlocal wrap -" setlocal nonumber norelativenumber +setlocal nonumber norelativenumber diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 17d07f6..c82d67a 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -25,6 +25,10 @@ api.nvim_set_keymap('t', '', '', {noremap = true, silent = true} api.nvim_set_keymap('v', '<', '', '>gv', {noremap = true, silent = true}) +-- Also move up/down virual lines (:set wrap) +api.nvim_set_keymap('n', 'j', 'gj', {noremap = true, silent = true}) +api.nvim_set_keymap('n', 'k', 'gk', {noremap = true, silent = true}) + -- winshift.nvim api.nvim_set_keymap('n', '', ':WinShift', {noremap = true, silent = true}) api.nvim_set_keymap('n', 'm', ':WinShift', {noremap = true, silent = true}) @@ -69,12 +73,12 @@ wk.register({ vim.opt.expandtab = false vim.opt.smarttab = false vim.opt.softtabstop = 0 -- reset to default - vim.notify('Switched to indent with tabs.', vim.log.levels.INFO) + vim.notify('Indent with Tabs.', vim.log.levels.INFO) else vim.opt.expandtab = true vim.opt.smarttab = true vim.opt.softtabstop = -1 -- fallback to shiftwidth - vim.notify('Switched to indent with spaces.', vim.log.levels.INFO) + vim.notify('Indent with Spaces.', vim.log.levels.INFO) end end, 'Switch indent style' @@ -215,7 +219,7 @@ wk.register({ name = 'Editor', a = {':EasyAlign', 'Align elements'}, g = 'Generate annotations', - h = {':TSHighlightCapturesUnderCursor', 'Syntax groups under cursor'}, + h = {':TSHighlightCapturesUnderCursor', 'Syntax under cursor'}, s = {':ISwapWith', 'Swap elements'}, t = {':Twilight', 'Twilight mode'}, v = { @@ -225,24 +229,27 @@ wk.register({ vim.b.venn_enabled = true vim.api.nvim_command('setlocal virtualedit=all') -- Draw lines with HJKL keystroke - vim.api.nvim_buf_set_keymap(0, 'n', '', 'h:VBox', {noremap = true, silent = true}) - vim.api.nvim_buf_set_keymap(0, 'n', '', 'j:VBox', {noremap = true, silent = true}) - vim.api.nvim_buf_set_keymap(0, 'n', '', 'k:VBox', {noremap = true, silent = true}) - vim.api.nvim_buf_set_keymap(0, 'n', '', 'l:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', 'H', 'h:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', 'J', 'j:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', 'K', 'k:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', 'L', 'l:VBox', {noremap = true, silent = true}) -- Draw boxes by pressing 'f' with visual selection vim.api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox', {noremap = true, silent = true}) - vim.notify('Virtual box edit enabled.', vim.log.levels.INFO) else vim.b.venn_enabled = nil vim.api.nvim_command('setlocal virtualedit=block') - -- vim.api.nvim_command('mapclear ') -- this also deletes buf keymap for lsp + -- vim.api.nvim_command('mapclear ') -- quicker, but also deletes buf keymap for lsp vim.api.nvim_buf_del_keymap(0, 'v', 'f') - vim.api.nvim_buf_del_keymap(0, 'n', '') - vim.api.nvim_buf_del_keymap(0, 'n', '') - vim.api.nvim_buf_del_keymap(0, 'n', '') - vim.api.nvim_buf_del_keymap(0, 'n', '') - + vim.api.nvim_buf_del_keymap(0, 'n', 'H') + vim.api.nvim_buf_del_keymap(0, 'n', 'J') + vim.api.nvim_buf_del_keymap(0, 'n', 'L') + local present, _ = pcall(require, 'lspconfig') -- Check to re-enable buf keymap for hover + if present then + vim.api.nvim_buf_set_keymap(0, 'n', 'K', ':lua vim.lsp.buf.hover()', {noremap = true, silent = true}) + else + vim.api.nvim_buf_del_keymap(0, 'n', 'K') + end vim.notify('Virtual box edit disabled.', vim.log.levels.INFO) end end, diff --git a/home/.config/nvim/lua/modules/completion.lua b/home/.config/nvim/lua/modules/completion.lua index 88f9488..c450112 100644 --- a/home/.config/nvim/lua/modules/completion.lua +++ b/home/.config/nvim/lua/modules/completion.lua @@ -10,6 +10,18 @@ function M.cmp_conf() end cmp.setup { + sorting = { + comparators = { + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + require('cmp-under-comparator').under, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order + } + }, formatting = { format = function(entry, vim_item) local lspkind_icons = { @@ -47,14 +59,11 @@ function M.cmp_conf() path = '[PATH]', buffer = '[BUF]', -- calc = '[CALC]', - -- nuspell = '[SPELL]', - spell = '[SPELL]', - emoji = '[EMOJI]', - -- treesitter = '[TS]', + dictionary = '[DICT]', + treesitter = '[TS]', nvim_lsp = '[LSP]', -- cmp_tabnine = '[TN]', latex_symbols = '[TEX]', - -- tmux = '[TMUX]', -- conjure = '[CJ]', orgmode = '[ORG]' })[entry.source.name] @@ -119,18 +128,19 @@ function M.cmp_conf() {name = 'path'}, {name = 'buffer'}, -- {name = 'calc'}, - -- {name = 'nuspell'}, - {name = 'spell'}, - {name = 'emoji'}, - -- {name = 'treesitter'}, + {name = 'dictionary', keyword_length = 2}, + {name = 'treesitter'}, {name = 'nvim_lsp'}, -- {name = 'cmp_tabnine'}, {name = 'latex_symbols'}, - -- {name = 'tmux'}, -- {name = 'conjure'}, {name = 'orgmode'} } } + + -- Setup for cmp-dictionary + -- TODO: do this on FileType * (cmp.setup.buffer) with custom dicts + -- vim.opt.dictionary = {'/usr/share/dict/words'} end -- function M.tabnine_conf() diff --git a/home/.config/nvim/lua/modules/editor.lua b/home/.config/nvim/lua/modules/editor.lua index d0b5934..829a4b3 100644 --- a/home/.config/nvim/lua/modules/editor.lua +++ b/home/.config/nvim/lua/modules/editor.lua @@ -236,16 +236,16 @@ function M.eft_conf() vim.g.eft_index_function = {all = function() return true end} -- Mappings - vim.api.nvim_set_keymap('n', 'f', '(eft-f)', {}) - vim.api.nvim_set_keymap('x', 'f', '(eft-f)', {}) - vim.api.nvim_set_keymap('n', 'F', '(eft-F)', {}) - vim.api.nvim_set_keymap('x', 'F', '(eft-F)', {}) - vim.api.nvim_set_keymap('n', 't', '(eft-t)', {}) - vim.api.nvim_set_keymap('x', 't', '(eft-t)', {}) - vim.api.nvim_set_keymap('n', 'T', '(eft-T)', {}) - vim.api.nvim_set_keymap('x', 'T', '(eft-T)', {}) - vim.api.nvim_set_keymap('n', ';', '(eft-repeat)', {}) - vim.api.nvim_set_keymap('x', ';', '(eft-repeat)', {}) + vim.api.nvim_set_keymap('n', 'f', '(eft-f)', {silent = true}) + vim.api.nvim_set_keymap('x', 'f', '(eft-f)', {silent = true}) + vim.api.nvim_set_keymap('n', 'F', '(eft-F)', {silent = true}) + vim.api.nvim_set_keymap('x', 'F', '(eft-F)', {silent = true}) + vim.api.nvim_set_keymap('n', 't', '(eft-t)', {silent = true}) + vim.api.nvim_set_keymap('x', 't', '(eft-t)', {silent = true}) + vim.api.nvim_set_keymap('n', 'T', '(eft-T)', {silent = true}) + vim.api.nvim_set_keymap('x', 'T', '(eft-T)', {silent = true}) + vim.api.nvim_set_keymap('n', ';', '(eft-repeat)', {silent = true}) + vim.api.nvim_set_keymap('x', ';', '(eft-repeat)', {silent = true}) end function M.dial_conf() @@ -294,12 +294,12 @@ function M.dial_conf() } -- Mappings - vim.api.nvim_set_keymap('n', '', '(dial-increment)', {}) - vim.api.nvim_set_keymap('v', '', '(dial-increment)', {}) - vim.api.nvim_set_keymap('n', '', '(dial-decrement)', {}) - vim.api.nvim_set_keymap('v', '', '(dial-decrement)', {}) - vim.api.nvim_set_keymap('v', 'g', '(dial-increment-additional)', {}) - vim.api.nvim_set_keymap('v', 'g', '(dial-decrement-additional)', {}) + vim.api.nvim_set_keymap('n', '', '(dial-increment)', {silent = true}) + vim.api.nvim_set_keymap('v', '', '(dial-increment)', {silent = true}) + vim.api.nvim_set_keymap('n', '', '(dial-decrement)', {silent = true}) + vim.api.nvim_set_keymap('v', '', '(dial-decrement)', {silent = true}) + vim.api.nvim_set_keymap('v', 'g', '(dial-increment-additional)', {silent = true}) + vim.api.nvim_set_keymap('v', 'g', '(dial-decrement-additional)', {silent = true}) end function M.comment_conf() diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 1b94224..30864dc 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -173,7 +173,7 @@ return packer.startup(function(use) -- LSP -- --------- local lsp = require('modules.lsp') - use { + use { -- TODO: reconsider lspsaga for actions 'neovim/nvim-lspconfig', event = 'BufReadPre', wants = {'lsp_signature.nvim', 'null-ls.nvim'}, @@ -232,24 +232,25 @@ return packer.startup(function(use) use { 'hrsh7th/nvim-cmp', event = 'InsertEnter', - wants = 'LuaSnip', - requires = {{ - 'L3MON4D3/LuaSnip', - wants = 'friendly-snippets', - requires = {{'rafamadriz/friendly-snippets', opt = true}}, - config = completion.snippets_conf, - opt = true - }}, + wants = {'LuaSnip', 'cmp-under-comparator'}, + requires = { + { + 'L3MON4D3/LuaSnip', + wants = 'friendly-snippets', + requires = {{'rafamadriz/friendly-snippets', opt = true}}, + config = completion.snippets_conf, + opt = true + }, + {'lukas-reineke/cmp-under-comparator', opt = true} + }, config = completion.cmp_conf } use {'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp'} use {'hrsh7th/cmp-path', after = 'nvim-cmp'} use {'hrsh7th/cmp-buffer', after = 'nvim-cmp'} -- use {'hrsh7th/cmp-calc', after = 'nvim-cmp'} - -- use {'f3fora/cmp-nuspell', after = 'nvim-cmp', rocks={'lua-nuspell'}} - use {'f3fora/cmp-spell', after = 'nvim-cmp'} - use {'hrsh7th/cmp-emoji', after = 'nvim-cmp'} - -- use {'ray-x/cmp-treesitter', after = {'nvim-cmp', 'nvim-treesitter'}} + use {'uga-rosa/cmp-dictionary', after = 'nvim-cmp'} -- TODO: scripts to curl dicts from aspell.net + use {'ray-x/cmp-treesitter', after = {'nvim-cmp', 'nvim-treesitter'}} use {'hrsh7th/cmp-nvim-lsp', after = {'nvim-cmp', 'nvim-lspconfig'}} -- use { -- 'tzachar/cmp-tabnine', @@ -258,7 +259,6 @@ return packer.startup(function(use) -- config = completion.tabnine_conf -- } use {'kdheepak/cmp-latex-symbols', after = 'nvim-cmp'} - -- use {'andersevenrud/compe-tmux', after = 'nvim-cmp', branch = 'cmp'} -- use {'PaterJason/cmp-conjure', after = {'conjure', 'nvim-cmp'}} use { 'windwp/nvim-autopairs', @@ -332,7 +332,7 @@ return packer.startup(function(use) opt = true }} } - use { + use { -- TODO: check out kat0h/bufpreview.vim 'iamcco/markdown-preview.nvim', run = 'cd app && yarn install', ft = {'markdown', 'rmd'},