From 7bc6dfc307f42e4fdab4b499a24ac221b31e9294 Mon Sep 17 00:00:00 2001 From: Henrik Bakken Date: Tue, 11 Apr 2023 01:52:37 +0200 Subject: [PATCH] nvim --- nvim/init.lua | 146 +++++++++++++++++--------------------------------- 1 file changed, 50 insertions(+), 96 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index cf535b2..0451e2a 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -75,21 +75,14 @@ require("lazy").setup({ end, }, { - "echasnovski/mini.jump", + "phaazon/hop.nvim", config = function() - require("mini.jump").setup({}) - end, - }, - { - "echasnovski/mini.jump2d", - config = function() - require("mini.jump2d").setup({}) - end, - }, - { - "echasnovski/mini.pairs", - config = function() - require("mini.pairs").setup({}) + require("hop").setup({ + require("hop.highlight").insert_highlights(), + }) + local map = vim.keymap.set + local opts = { silent = true, noremap = true } + map({ "n", "v" }, "", "HopWord", opts) end, }, { @@ -133,10 +126,10 @@ require("lazy").setup({ vim.g.tmux_navigator_disable_when_zoomed = 1 local map = vim.keymap.set local opts = { silent = true, noremap = true } - map("n", "", ":TmuxNavigateLeft", opts) - map("n", "", ":TmuxNavigateDown", opts) - map("n", "", ":TmuxNavigateUp", opts) - map("n", "", ":TmuxNavigateRight", opts) + map("n", "", "TmuxNavigateLeft", opts) + map("n", "", "TmuxNavigateDown", opts) + map("n", "", "TmuxNavigateUp", opts) + map("n", "", "TmuxNavigateRight", opts) end, }, { @@ -177,7 +170,7 @@ require("lazy").setup({ config = function() -- Unless you are still migrating, remove the deprecated commands from v1.x vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) - vim.keymap.set("n", "", ":NeoTreeFocusToggle", { noremap = true }) + vim.keymap.set("n", "", "NeoTreeFocusToggle", { noremap = true }) end, }, -- theme dark and light "NLKNguyen/papercolor-theme", @@ -202,18 +195,6 @@ require("lazy").setup({ config = function() vim.g.Hexokinase_highlighters = { "virtual" } end, - }, - { - -- flashing cursor on move - "danilamihailov/beacon.nvim", - init = function() - vim.api.nvim_exec([[highlight Beacon guibg=white ctermbg=15]], false) - end, - config = function() - vim.g.beacon_size = 40 - vim.g.beacon_minimal_jump = 10 - vim.g.beacon_shrink = 1 - end, }, -- status + buffer lines { "nvim-lualine/lualine.nvim", @@ -263,30 +244,30 @@ require("lazy").setup({ config = function() require("bufferline").setup({ options = { diagnostics = "nvim_lsp" } }) local map = vim.keymap.set - map("n", "", ":BufferLineCyclePrev", { noremap = true, silent = true }) - map("n", "", ":BufferLineCycleNext", { noremap = true, silent = true }) - map("n", "", ":BufferLineMovePrev", { noremap = true, silent = true }) - map("n", "", ":BufferLineMoveNext", { noremap = true, silent = true }) + map("n", "", "BufferLineCyclePrev", { noremap = true, silent = true }) + map("n", "", "BufferLineCycleNext", { noremap = true, silent = true }) + map("n", "", "BufferLineMovePrev", { noremap = true, silent = true }) + map("n", "", "BufferLineMoveNext", { noremap = true, silent = true }) end, }, -- git related plugins { "tpope/vim-fugitive", config = function() local map = vim.keymap.set - map("", "", ":vertical Git:vertical resize 60", {}) - map("", "gl", ":Git log --oneline", {}) - map("", "gL", ":Gclog", {}) - map("", "gB", ":Git blame", {}) - map("", "gp", ":Git! push", {}) - map("", "gP", ":Git! push -f", {}) + map("", "", "vertical Git:vertical resize 60", {}) + map("", "gl", "Git log --oneline", {}) + map("", "gL", "Gclog", {}) + map("", "gB", "Git blame", {}) + map("", "gp", "Git push", {}) + map("", "gP", "Git push -f", {}) end, }, { "rbong/vim-flog", config = function() local map = vim.keymap.set - map("", "gg", ":vertical Flogsplit -path=%", {}) - map("", "gG", ":vertical Flogsplit", {}) + map("", "gg", "vertical Flogsplit -path=%", {}) + map("", "gG", "vertical Flogsplit", {}) end, }, { @@ -345,7 +326,7 @@ require("lazy").setup({ map("n", "tn", gs.toggle_numhl) -- Text object - map({ "o", "x" }, "ih", ":Gitsigns select_hunk") + map({ "o", "x" }, "ih", "Gitsigns select_hunk") end, }) end, @@ -508,34 +489,6 @@ require("lazy").setup({ }, }) end, - }, - { -- context while scrolling - "romgrk/nvim-treesitter-context", - dependencies = { "nvim-treesitter/nvim-treesitter" }, - config = function() - require("treesitter-context").setup({ - enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) - throttle = true, -- Throttles plugin updates (may improve performance) - max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. - patterns = { - default = { - "class", - "function", - "method", - -- 'for', -- These won't appear in the context - -- 'while', - -- 'if', - -- 'switch', - -- 'case', - }, - -- Example for a specific filetype. - -- If a pattern is missing, *open a PR* so everyone can benefit. - -- rust = { - -- 'impl_item', - -- }, - }, - }) - end, }, -- package manager + lsp stuff { "williamboman/mason.nvim", @@ -646,7 +599,7 @@ require("lazy").setup({ vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) vim.lsp.buf.format({ timeout_ms = 5000 }) end, { desc = "Format current buffer with LSP" }) - bmap("n", "f", ":Format") + bmap("n", "f", "Format") if client.server_capabilities.documentFormattingProvider or client.server_capabilities.documentRangeFormattingProvider @@ -756,10 +709,9 @@ vim.o.shell = "/usr/bin/bash" vim.o.fileencodings = "utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" vim.o.fileformats = "unix" vim.o.swapfile = false -vim.o.updatetime = 300 -vim.o.timeoutlen = 200 vim.g.BASH_Ctrl_j = "off" vim.g.BASH_Ctrl_l = "off" +-- TODO remove in commands -- colors vim.cmd("colorscheme minicyan") @@ -770,7 +722,9 @@ vim.o.undoreload = 10000 -- buffer vim.o.hidden = true -- Enable background buffers -vim.o.relativenumber = true -- Relative line numbers +vim.o.number = false +vim.o.relativenumber = false +vim.o.cursorline = false vim.o.switchbuf = "useopen" -- Use existing window if buffer is already open vim.o.colorcolumn = "88" @@ -832,7 +786,7 @@ map("n", "q:", "", { noremap = true }) map({ "n", "v" }, "", "", { silent = true }) map("n", "e", [[:vnew ~/dotfiles/nvim/init.lua]], { noremap = true }) map("n", "ww", [[:cd %:p:h]], { noremap = true }) -map("n", "", ":noh", { silent = true, noremap = true }) +map("n", "", "noh", { silent = true, noremap = true }) map("", "", "", { silent = true, noremap = true }) -- to navigate the completion menu @@ -851,36 +805,36 @@ map("n", "\\", "n.", { noremap = true }) -- WINDOWS / BUFFERS -- make splits and tabs -map("n", "", ":vnew", { noremap = true }) -map("n", "", ":new", { noremap = true }) -map("n", "", ":vsplit", { noremap = true }) -map("n", "", ":split", { noremap = true }) -map("n", "", ":tabe %", { noremap = true }) -map("n", "", ":tabnew", { noremap = true }) +map("n", "", "vnew", { noremap = true }) +map("n", "", "new", { noremap = true }) +map("n", "", "vsplit", { noremap = true }) +map("n", "", "split", { noremap = true }) +map("n", "", "tabe %", { noremap = true }) +map("n", "", "tabnew", { noremap = true }) -- buffers and tabs -map("n", "", ":bprev", { noremap = true }) -map("n", "", ":bnext", { noremap = true }) -map("n", "", ":tabprev", { noremap = true }) -map("n", "", ":tabnext", { noremap = true }) +map("n", "", "bprev", { noremap = true }) +map("n", "", "bnext", { noremap = true }) +map("n", "", "tabprev", { noremap = true }) +map("n", "", "tabnext", { noremap = true }) -- resize windows with hjkl map("n", "", "5<", { noremap = true }) map("n", "", "5-", { noremap = true }) map("n", "", "5+", { noremap = true }) map("n", "", "5>", { noremap = true }) -- quickfix window -map("n", "", ":cp", { noremap = true }) -map("n", "", ":cn", { noremap = true }) +map("n", "", "cp", { noremap = true }) +map("n", "", "cn", { noremap = true }) --- F keys -map("n", "", ":Lazy", { noremap = true }) -map("n", "", ":Mason", { noremap = true }) -map("n", "", ":LspInfo", { noremap = true }) -map("n", "", ":NullLsInfo", { noremap = true }) -map("n", "", ":checkt", { noremap = true }) -map("n", "", ":TodoQuickFix", { noremap = true }) +map("n", "", "Lazy", { noremap = true }) +map("n", "", "Mason", { noremap = true }) +map("n", "", "LspInfo", { noremap = true }) +map("n", "", "NullLsInfo", { noremap = true }) +map("n", "", "checkt", { noremap = true }) +map("n", "", "TodoQuickFix", { noremap = true }) map("n", "", 'lua require("telescope.builtin").colorscheme({enable_preview=1})', { noremap = true }) -- shit HACK -map("n", "b", ":!blackdoc %", { noremap = true }) +map("n", "b", "!blackdoc %", { noremap = true }) -- cursor color