From a4ca205f1fd716291d2eaa571b397b6d2cbeaa78 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Tue, 17 May 2022 00:54:27 +0300 Subject: nvim: neovim 0.7 keymaps, plugins --- .config/nvim/lua/mappings.lua | 188 +++++++++++++++++++++--------------------- .config/nvim/lua/plugins.lua | 20 ++++- 2 files changed, 111 insertions(+), 97 deletions(-) (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index 3a37584..a324d90 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -5,168 +5,168 @@ -- │▘▝ ▘▝▀▘▌ ▌ ▀▘▘ ▘▗▄▘▀▀ │ -- └────────────────────────┘ --- map helper -local function map(mode, lhs, rhs, opts) - local options = {noremap = true, silent = true} - if opts then options = vim.tbl_extend('force', options, opts) end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) -end +-- -- map helper +-- local function map(mode, lhs, rhs, opts) +-- local options = {noremap = true, silent = true} +-- if opts then options = vim.tbl_extend('force', options, opts) end +-- vim.api.nvim_set_keymap(mode, lhs, rhs, options) +-- end -local cmd = vim.cmd -local M = {} +-- local cmd = vim.cmd +-- local M = {} -- brute force deasciify everything -map('n', 'tc', 'TurkishDeasciifyForce()', {expr = true}) -map('x', 'tc', 'TurkishDeasciifyForce()', {expr = true}) -map('n', 'tctc', "TurkishDeasciifyForce() .. '_'", {expr = true}) +vim.keymap.set("n", "tc", "TurkishDeasciifyForce()", { expr = true }) +vim.keymap.set("n", "tctc", "TurkishDeasciifyForce() .. '_'", { expr = true }) +vim.keymap.set("x", "tc", "TurkishDeasciifyForce()", { expr = true }) -- use turkish-mode to selectively deasciify -map('n', 'tr', 'TurkishDeasciify()', {expr = true}) -map('x', 'tr', 'TurkishDeasciify()', {expr = true}) -map('n', 'trtr', "TurkishDeasciify() .. '_'", {expr = true}) +vim.keymap.set("n", "tr", "TurkishDeasciify()", {expr = true}) +vim.keymap.set("n", "trtr", "TurkishDeasciify() .. '_'", {expr = true}) +vim.keymap.set("x", "tr", "TurkishDeasciify()", {expr = true}) -- ascii everything -map('n', 'rt', 'TurkishAsciify()', {expr = true}) -map('x', 'rt', 'TurkishAsciify()', {expr = true}) -map('n', 'rtrt', "TurkishAsciify() .. '_'", {expr = true}) +vim.keymap.set("n", "rt", "TurkishAsciify()", {expr = true}) +vim.keymap.set("n", "rtrt", "TurkishAsciify() .. '_'", {expr = true}) +vim.keymap.set("x", "rt", "TurkishAsciify()", {expr = true}) -- https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump -- search & highlight but do not jump -map('n', '*', ':keepjumps normal! mi*`i') -map('n', '#', ':keepjumps normal! mi#`i ') +vim.keymap.set("n", "*", ":keepjumps normal! mi*`i") +vim.keymap.set("n", "#", ":keepjumps normal! mi#`i") -- save file as sudo on files that require root permission -map('c', 'w!!', 'execute "silent! write !sudo tee % >/dev/null" edit!', { silent = false }) +vim.keymap.set("c", "w!!", 'execute "silent! write !sudo tee % >/dev/null" edit!', { silent = false }) -- replace ex mode with gq (format lines) -map('n', 'Q', 'gq') +vim.keymap.set('n', 'Q', 'gq') -- set formatprg to sentences, for prose -map('n', 'fp', ":set formatprg=~/.local/bin/sentences", { silent = false }) +vim.keymap.set('n', 'fp', ":set formatprg=~/.local/bin/sentences", { silent = false }) -- replace all is aliased to S. -map('n', 'S', ':%s//g', { silent = false }) -map('v', 'S', ':s//g', { silent = false }) +vim.keymap.set('n', 'S', ':%s//g', { silent = false }) +vim.keymap.set('v', 'S', ':s//g', { silent = false }) -- jump to buffer -map('n', 'b', ':ls:b') +vim.keymap.set('n', 'b', ':ls:b') -- up and down are more logical with g.. -map('n', 'k', '(v:count == 0 ? "gk" : "k")', { expr = true }) -map('n', 'j', '(v:count == 0 ? "gj" : "j")', { expr = true }) -map('i', '', 'gka') -map('i', '', 'gja') +vim.keymap.set('n', 'k', '(v:count == 0 ? "gk" : "k")', { expr = true }) +vim.keymap.set('n', 'j', '(v:count == 0 ? "gj" : "j")', { expr = true }) +vim.keymap.set('i', '', 'gka') +vim.keymap.set('i', '', 'gja') --- disable highlight when is pressed -map('n', '', ':noh') -- space used to toggle folds, now it's x (because x is d) -map('n', '', '"_x') +vim.keymap.set('n', '', '"_x') -- separate cut and delete -map('n', 'x', 'd') -map('x', 'x', 'd') -map('n', 'xx', 'dd') -map('n', 'X', 'D') +vim.keymap.set('n', 'x', 'd') +vim.keymap.set('x', 'x', 'd') +vim.keymap.set('n', 'xx', 'dd') +vim.keymap.set('n', 'X', 'D') -- change into pwd of current directory -map('n', 'cd', ':lcd %:p:h:pwd') +vim.keymap.set('n', 'cd', ':lcd %:p:h:pwd') -- press \g and start writing prose -map('n', 'g', ':Goyo') +vim.keymap.set('n', 'g', ':Goyo') -- call CreatePaper on word below cursor -map('n', 'np', 'gewi[[/papers/Ea]]bb:call CreatePaper(expand(""))') +vim.keymap.set('n', 'np', 'gewi[[/papers/Ea]]bb:call CreatePaper(expand(""))') -- link paper -map('n', 'lp', 'gewi[[/papers/Ea]]') +vim.keymap.set('n', 'lp', 'gewi[[/papers/Ea]]') -- call CreateReference on word below cursor -map('n', 'nr', ':call CreateReference(expand(""))') +vim.keymap.set('n', 'nr', ':call CreateReference(expand(""))') -- create a new note -map('n', 'nn', ':call CreateNote()') +vim.keymap.set('n', 'nn', ':call CreateNote()') -- :%% to get current file path -map('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", { expr = true, silent = false }) +vim.keymap.set('c', '%%', "getcmdtype() == ':' ? expand('%:h').'/' : '%%'", { expr = true, silent = false }) -- reselect visual selection after indent -map('v', '>', '>gv') -map('v', '<', '', '>gv') +vim.keymap.set('v', '<', ' mappings should not be noremap --- https://www.reddit.com/r/vim/comments/78izt4/please_help_understand_how_to_use_plug_mapping/ -local function plugmap(mode, lhs, rhs, opts) - local options = {noremap = false, silent = true} - if opts then options = vim.tbl_extend('force', options, opts) end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) -end - --- open the TagBar Plugin -plugmap('n', '', ':TagbarToggle') +-- New vim.keymap.set handles Plug mappings, I think, remove this paragraph if nothing breaks in the upcoming days +-- -- mappings should not be noremap +-- -- https://www.reddit.com/r/vim/comments/78izt4/please_help_understand_how_to_use_plug_mapping/ +-- local function plugmap(mode, lhs, rhs, opts) +-- local options = {noremap = false, silent = true} +-- if opts then options = vim.tbl_extend('force', options, opts) end +-- vim.api.nvim_set_keymap(mode, lhs, rhs, options) +-- end -- sneak using grave, s is for sandwich -plugmap('n', '`', 'Sneak_s') -plugmap('n', '`', 'Sneak_s') -plugmap('n', '`', 'Sneak_S') -map('n', "'", '`') +vim.keymap.set('n', '`', 'Sneak_s') +vim.keymap.set('n', '`', 'Sneak_s') +vim.keymap.set('n', '`', 'Sneak_S') +vim.keymap.set('n', "'", '`') -- use the special yoink paste that rotates -plugmap('n', 'p', '(YoinkPaste_p)') -plugmap('n', 'P', '(YoinkPaste_P)') +vim.keymap.set('n', 'p', '(YoinkPaste_p)') +vim.keymap.set('n', 'P', '(YoinkPaste_P)') -- substitute from yank -plugmap('n', 'ys', '(SubversiveSubstitute)') -plugmap('n', 'yss', '(SubversiveSubstituteLine)') -plugmap('n', 'yS', '(SubversiveSubstituteToEndOfLine)') +vim.keymap.set('n', 'ys', '(SubversiveSubstitute)') +vim.keymap.set('n', 'yss', '(SubversiveSubstituteLine)') +vim.keymap.set('n', 'yS', '(SubversiveSubstituteToEndOfLine)') -- substitute over range -plugmap('n', 's', '(SubversiveSubstituteRange)') -plugmap('x', 's', '(SubversiveSubstituteRange)') -plugmap('n', 'ss', '(SubversiveSubstituteWordRange)') +vim.keymap.set('n', 's', '(SubversiveSubstituteRange)') +vim.keymap.set('x', 's', '(SubversiveSubstituteRange)') +vim.keymap.set('n', 'ss', '(SubversiveSubstituteWordRange)') -- subvert over range -plugmap('n', 's', '(SubversiveSubvertRange)') -plugmap('x', 's', '(SubversiveSubvertRange)') -plugmap('n', 'ss', '(SubversiveSubvertWordRange)') +vim.keymap.set('n', 's', '(SubversiveSubvertRange)') +vim.keymap.set('x', 's', '(SubversiveSubvertRange)') +vim.keymap.set('n', 'ss', '(SubversiveSubvertWordRange)') -- iterate over yank list -plugmap('n', '', '(YoinkPostPasteSwapBack)') -plugmap('n', '', '(YoinkPostPasteSwapForward)') +vim.keymap.set('n', '', '(YoinkPostPasteSwapBack)') +vim.keymap.set('n', '', '(YoinkPostPasteSwapForward)') -- checkmarks on vimwiki -plugmap('n', 'v', 'VimwikiToggleListItem') +vim.keymap.set('n', 'v', 'VimwikiToggleListItem') -- add/increase header level -plugmap('n', 'a', 'VimwikiAddHeaderLevel') +vim.keymap.set('n', 'a', 'VimwikiAddHeaderLevel') -- vim-test bindings -map('n', 't', ':TestNearest') -map('n', 't', ':TestFile') -map('n', 't', ':TestSuite') -map('n', 't', ':TestLast') -map('n', 't', ':TestVisit') +vim.keymap.set('n', 't', ':TestNearest') +vim.keymap.set('n', 't', ':TestFile') +vim.keymap.set('n', 't', ':TestSuite') +vim.keymap.set('n', 't', ':TestLast') +vim.keymap.set('n', 't', ':TestVisit') -- telescope bindings -map('n', 'ff', "lua require('telescope.builtin').find_files()") -map('n', 'fg', "lua require('telescope.builtin').live_grep()") -map('n', 'fb', "lua require('telescope.builtin').buffers()") -map('n', 'fh', "lua require('telescope.builtin').help_tags()") +vim.keymap.set('n', 'ff', "lua require('telescope.builtin').find_files()") +vim.keymap.set('n', 'fg', "lua require('telescope.builtin').live_grep()") +vim.keymap.set('n', 'fb', "lua require('telescope.builtin').buffers()") +vim.keymap.set('n', 'fh', "lua require('telescope.builtin').help_tags()") -- vista -map('n', '', ":Vista focus") -map('n', '', ":Vista finder") - --- toggle rose pine theme -map('n', '', [[lua require('rose-pine.functions').toggle_variant({'dawn', 'base'})]], { noremap = true, silent = true }) +vim.keymap.set('n', '', ":Vista focus") +vim.keymap.set('n', '', ":Vista finder") -- nvim tree mappings -map('n', 'vt', ':NvimTreeToggle') -map('n', 'vr', ':NvimTreeRefresh') -map('n', 'vs', ':NvimTreeFindFile') +vim.keymap.set('n', 'vt', ':NvimTreeToggle') +vim.keymap.set('n', 'vr', ':NvimTreeRefresh') +vim.keymap.set('n', 'vs', ':NvimTreeFindFile') + +-- dial.nvim mappings +vim.keymap.set("n", "", require("dial.map").inc_normal(), {noremap = true}) +vim.keymap.set("n", "", require("dial.map").dec_normal(), {noremap = true}) +vim.keymap.set("v", "", require("dial.map").inc_visual(), {noremap = true}) +vim.keymap.set("v", "", require("dial.map").dec_visual(), {noremap = true}) +vim.keymap.set("v", "g", require("dial.map").inc_gvisual(), {noremap = true}) +vim.keymap.set("v", "g", require("dial.map").dec_gvisual(), {noremap = true}) -- }}} plug mappings -- diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 3266aeb..a217616 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -19,6 +19,18 @@ return require('packer').startup(function() } -- quickstart lsp config use 'neovim/nvim-lspconfig' + + -- annotation generator + -- learn to use it 2022-05-17 00:44 + -- https://github.com/danymat/neogen + use { + "danymat/neogen", + config = function() + require('neogen').setup {} + end, + requires = "nvim-treesitter/nvim-treesitter", + } + -- dashboard use { 'goolord/alpha-nvim', @@ -67,7 +79,6 @@ return require('packer').startup(function() -- file explorer use 'kyazdani42/nvim-tree.lua' - -- viewer & finder for lsp symbols and tags use 'liuchengxu/vista.vim' @@ -77,6 +88,7 @@ return require('packer').startup(function() cmd = 'UndotreeToggle', config = [[vim.g.undotree_SetFocusWhenToggle = 1]], } + -- highlight colors use 'norcalli/nvim-colorizer.lua' @@ -112,6 +124,8 @@ return require('packer').startup(function() use 'justinmk/vim-sneak' -- additional text objects, don't remove this ever again you fuck use 'wellle/targets.vim' + -- enhanced increment/decrement plugin ala speeddating + use 'monaqa/dial.nvim' -- statusline of the $CURRENT_YEAR use { @@ -121,6 +135,8 @@ return require('packer').startup(function() -- colour theme of the $CURRENT_YEAR use 'rose-pine/neovim' + -- search for, substitute, and abbreviate multiple variants of a word + use 'tpope/vim-abolish' -- enable repeating supported plugin maps with '.' use 'tpope/vim-repeat' -- pairs of handy bracket mappings @@ -129,8 +145,6 @@ return require('packer').startup(function() use { 'tpope/vim-fugitive', cmd = {'Git', 'Gstatus', 'Gblame', 'Gpush', 'Gpull'} } - -- increment dates, times & more - use 'tpope/vim-speeddating' -- provides ga, show unicode stuff of char under cursor use 'tpope/vim-characterize' -- comment helper -- cgit v1.2.3-70-g09d2