From 415f88a10d86dbceb3ff3671d05a11d5ce8fb85d Mon Sep 17 00:00:00 2001 From: Akos Horvath Date: Tue, 15 Aug 2023 18:09:15 +0200 Subject: [PATCH] add hop.nvim plugin --- init.lua | 19 ++++++++++++++++--- lua/keymap.lua | 9 +++++++++ lua/option.lua | 3 ++- lua/plugin.lua | 46 +++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/init.lua b/init.lua index 7d79e2e..7c73326 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -vim.opt.runtimepath:append(',~/.config/nvim/lua') +-- vim.opt.runtimepath:append(',~/.config/nvim/lua') require "plugin" -- Automatically source and re-compile packer whenever you save this init.lua @@ -260,10 +260,23 @@ require('fidget').setup() -- -- vim.cmd([[COQnow -s]]) +local hop = require('hop') +local directions = require('hop.hint').HintDirection +vim.keymap.set('n', 'f', function() + hop.hint_words({ direction = directions.AFTER_CURSOR, current_line_only = false }) +end, {remap=true}) + +vim.keymap.set('n', 'F', function() + hop.hint_words({ direction = directions.BEFORE_CURSOR, current_line_only = false }) +end, {remap=true}) + -- nvim-cmp setup local cmp = require 'cmp' local luasnip = require 'luasnip' +-- load luasnip snippets +-- require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/luasnip/"}) + cmp.setup { snippet = { expand = function(args) @@ -290,8 +303,8 @@ cmp.setup { [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - -- elseif luasnip.jumpable(-1) then - -- luasnip.jump(-1) + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() else fallback() end diff --git a/lua/keymap.lua b/lua/keymap.lua index 9b0296a..8d1325f 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -20,6 +20,15 @@ vim.keymap.set('n', '', 'j', {desc = 'window navigation', silent = tru vim.keymap.set('n', '', 'k', {desc = 'window navigation', silent = true}) vim.keymap.set('n', '', 'l', {desc = 'window navigation', silent = true}) +-- toggleterm +-- todo: maybe can use these kybindings simultaneously with hidden attribute +-- https://github.com/akinsho/toggleterm.nvim/issues/322 +vim.keymap.set('n', '', 'ToggleTerm direction=float', {desc = 'floating terminal'}) +vim.keymap.set('t', '', 'exit', {desc = 'floating terminal'}) + +vim.keymap.set('n', '', 'ToggleTerm direction=horizontal', {desc = 'horizontal terminal'}) +vim.keymap.set('t', '', 'ToggleTerm', {desc = 'horizontal terminal'}) + -- vsplit vim.keymap.set('n', '<|>', ':vsplit', {desc = 'Vertical split', remap = true}) diff --git a/lua/option.lua b/lua/option.lua index 61c2ca1..e6202fa 100644 --- a/lua/option.lua +++ b/lua/option.lua @@ -3,13 +3,14 @@ -- tabs vim.o.tabstop = 4 +vim.o.expandtab = true vim.o.shiftwidth = 4 -- Set highlight on search vim.o.hlsearch = false -- Make line numbers default --- vim.wo.number = true +vim.wo.number = true vim.wo.relativenumber = true -- Enable mouse mode diff --git a/lua/plugin.lua b/lua/plugin.lua index 8b0b2bc..9930dd2 100644 --- a/lua/plugin.lua +++ b/lua/plugin.lua @@ -11,6 +11,12 @@ require('packer').startup({function(use) -- Package manager use 'wbthomason/packer.nvim' + use { + -- Useful status updates for LSP + 'j-hui/fidget.nvim', + branch = 'legacy', + } + use { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', requires = { @@ -18,8 +24,6 @@ require('packer').startup({function(use) 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', - -- Useful status updates for LSP - 'j-hui/fidget.nvim', -- Additional lua configuration, makes nvim stuff amazing 'folke/neodev.nvim', @@ -38,6 +42,15 @@ require('packer').startup({function(use) end } + use { + 'phaazon/hop.nvim', + branch = 'v2', -- optional but strongly recommended + config = function() + -- you can configure Hop the way you like here; see :h hop-config + require'hop'.setup { keys = 'etovxqpdgfblzhckisuran' } + end + } + use { -- Autocompletion 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, @@ -61,6 +74,9 @@ require('packer').startup({function(use) pcall(require('nvim-treesitter.install').update { with_sync = true }) end, } + use { + 'nvim-treesitter/playground', +} use { -- Additional text objects via treesitter 'nvim-treesitter/nvim-treesitter-textobjects', @@ -77,9 +93,28 @@ require('packer').startup({function(use) -- your configuration comes here -- or leave it empty to use the default settings -- refer to the configuration section below + -- plugins = { + -- marks = true, -- shows a list of your marks on ' and ` + -- registers = false, -- shows your registers on " in NORMAL or in INSERT mode + -- -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- -- No actual key bindings are created + -- spelling = { + -- enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions + -- suggestions = 20, -- how many suggestions should be shown in the list? + -- }, + -- presets = { + -- operators = true, -- adds help for operators like d, y, ... + -- motions = true, -- adds help for motions + -- text_objects = true, -- help for text objects triggered after entering an operator + -- windows = true, -- default bindings on + -- nav = true, -- misc bindings to work with windows + -- z = true, -- bindings for folds, spelling and others prefixed with z + -- g = true, -- bindings for prefixed with g + -- }, + -- }, } end - } +} -- file explorer use { @@ -99,8 +134,7 @@ require('packer').startup({function(use) -- toggleterm use {"akinsho/toggleterm.nvim", tag = '*', config = function() require("toggleterm").setup{ - open_mapping = [[]], - + open_mapping = [[]], } end} @@ -121,6 +155,8 @@ require('packer').startup({function(use) use 'tpope/vim-rhubarb' use 'lewis6991/gitsigns.nvim' + use 'lervag/vimtex' + use 'sainnhe/sonokai' use 'navarasu/onedark.nvim' -- Theme inspired by Atom use 'nvim-lualine/lualine.nvim' -- Fancier statusline