From ec950f9d196b54bbe382a035f01d12fcd172a9b8 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Wed, 17 Aug 2022 15:53:34 +0300 Subject: nvim: bring in leap.nvim, vim.keymap.set --- .config/nvim/lua/mappings.lua | 46 ++++++----------- .config/nvim/lua/plugin_settings.lua | 96 ++++++++++++++++++++++++++---------- .config/nvim/lua/plugins.lua | 11 +++-- 3 files changed, 94 insertions(+), 59 deletions(-) (limited to '.config') diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index a324d90..db2a552 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -5,16 +5,6 @@ -- │▘▝ ▘▝▀▘▌ ▌ ▀▘▘ ▘▗▄▘▀▀ │ -- └────────────────────────┘ --- -- 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 = {} - -- brute force deasciify everything vim.keymap.set("n", "tc", "TurkishDeasciifyForce()", { expr = true }) vim.keymap.set("n", "tctc", "TurkishDeasciifyForce() .. '_'", { expr = true }) @@ -95,22 +85,11 @@ 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 - --- sneak using grave, s is for sandwich -vim.keymap.set('n', '`', 'Sneak_s') -vim.keymap.set('n', '`', 'Sneak_s') -vim.keymap.set('n', '`', 'Sneak_S') +-- ` is more useful than ` vim.keymap.set('n', "'", '`') +-- plug mappings {{{ -- + -- use the special yoink paste that rotates vim.keymap.set('n', 'p', '(YoinkPaste_p)') vim.keymap.set('n', 'P', '(YoinkPaste_P)') @@ -162,11 +141,18 @@ 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}) +local opts = { noremap=true, silent=true } +vim.keymap.set("n", "", require("dial.map").inc_normal(), opts) +vim.keymap.set("n", "", require("dial.map").dec_normal(), opts) +vim.keymap.set("v", "", require("dial.map").inc_visual(), opts) +vim.keymap.set("v", "", require("dial.map").dec_visual(), opts) +vim.keymap.set("v", "g", require("dial.map").inc_gvisual(), opts) +vim.keymap.set("v", "g", require("dial.map").dec_gvisual(), opts) + +-- leap.nvim mappings +vim.keymap.set('n', '`', '(leap-forward)', opts) +vim.keymap.set('n', '`', '(leap-backward)', opts) +vim.keymap.set('v', '`', '(leap-forward)', opts) +vim.keymap.set('v', '`', '(leap-backward)', opts) -- }}} plug mappings -- diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index 41a663a..734efd3 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua @@ -38,11 +38,6 @@ local function lualine_spell() end end --- Grinds vim to a halt -local function lualine_tex_wordcount() - return vim.fn['vimtex#misc#wordcount']() .. " ‽" -end - local conditions = { spell_on = function () return vim.wo.spell @@ -337,38 +332,38 @@ local nvim_lsp = require('lspconfig') -- Mappings. local opts = { noremap=true, silent=true } -vim.api.nvim_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) -vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) -vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) -vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) local on_attach = function(client, bufnr) -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') -- See `:help vim.lsp.*` for documentation on any of the below functions - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'vh', 'lua vim.lsp.buf.hover()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gh', 'lua vim.lsp.buf.implementation()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'fm', 'lua vim.lsp.buf.formatting()', opts) + local bufopts = { noremap=true, silent=true, buffer=bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'vh', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gh', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'fm', vim.lsp.buf.formatting, bufopts) end local servers = { 'rust_analyzer', 'jedi_language_server', 'texlab', 'clangd', 'ltex' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, - flags = { - debounce_text_changes = 150, - }, capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) } end @@ -555,3 +550,54 @@ require('rose-pine').setup({ -- set colorscheme after options vim.cmd('colorscheme rose-pine') -- }}} Rose Pine -- + +-- dial.nvim {{{ -- + +local augend = require("dial.augend") +require("dial.config").augends:register_group{ + -- default augends used when no group name is specified + default = { + augend.integer.alias.decimal, -- nonnegative decimal number (0, 1, 2, 3, ...) + augend.integer.alias.hex, -- nonnegative hex number (0x01, 0x1a1f, etc.) + augend.date.alias["%Y/%m/%d"], -- date (2022/02/19, etc.) + augend.date.alias["%Y-%m-%d"], + augend.semver.alias.semver, + augend.constant.new{ + elements = {"and", "or"}, + word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. + cyclic = true, -- "or" is incremented into "and". + }, + augend.constant.new{ + elements = {"&&", "||"}, + word = false, + cyclic = true, + }, + }, +} + +-- }}} dial.nvim -- + +-- leap.nvim {{{ -- +require('leap').setup { + max_aot_targets = nil, + highlight_unlabeled = false, + case_sensitive = false, + -- Groups of characters that should match each other. + -- Obvious candidates are braces & quotes ('([{', ')]}', '`"\''). + character_classes = { ' \t\r\n', }, + -- Leaving the appropriate list empty effectively disables "smart" mode, + -- and forces auto-jump to be on or off. + -- safe_labels = { . . . }, + -- labels = { . . . }, + -- These keys are captured directly by the plugin at runtime. + -- (For `prev_match`, I suggest if possible in the terminal/GUI.) + special_keys = { + repeat_search = '', + next_match = '', + prev_match = '', + next_group = '', + prev_group = '', + }, +} + +-- }}} leap.nvim -- diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index ba5ae0b..2628272 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -125,12 +125,17 @@ return require('packer').startup(function() use 'lfv89/vim-interestingwords' -- swap delimited items using g>, g< use 'machakann/vim-swap' - -- jump to location by 2 characters, ` - use 'justinmk/vim-sneak' + + -- sneak, but in l u a + use 'ggandor/leap.nvim' + -- -- jump to location by 2 characters, ` + -- 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' + -- comment helper + use 'numToStr/Comment.nvim' -- statusline of the $CURRENT_YEAR use { @@ -152,8 +157,6 @@ return require('packer').startup(function() } -- provides ga, show unicode stuff of char under cursor use 'tpope/vim-characterize' - -- comment helper - use 'numToStr/Comment.nvim' -- asynchronous build and test dispatcher use {'tpope/vim-dispatch', opt = true, cmd = {'Dispatch', 'Make', 'Focus', 'Start'}} -- automatically adjust 'shiftwidth' and 'expandtab' -- cgit v1.2.3-70-g09d2