From a56c3f9a2bcf0d6cfa91d7394b13f6c34328e3dc Mon Sep 17 00:00:00 2001 From: lorenzhohermuth Date: Sun, 11 Feb 2024 12:03:53 +0100 Subject: [PATCH] removed submod for git --- .config/nvim | 1 - .config/nvim/.nvimrc | 146 ++++++ .config/nvim/init.lua | 1 + .config/nvim/lazy-lock.json | 34 ++ .config/nvim/lua/lorenz/autoclose.lua | 7 + .config/nvim/lua/lorenz/catppuccin.lua | 49 ++ .config/nvim/lua/lorenz/cmp.lua | 50 ++ .config/nvim/lua/lorenz/golsp-config.lua | 17 + .config/nvim/lua/lorenz/harpoon.lua | 17 + .config/nvim/lua/lorenz/init.lua | 9 + .config/nvim/lua/lorenz/kickstart.lua | 576 +++++++++++++++++++++++ .config/nvim/lua/lorenz/nvim-tree.lua | 14 + .config/nvim/lua/lorenz/remap.lua | 23 + .config/nvim/lua/lorenz/set.lua | 54 +++ .config/nvim/lua/lorenz/undotree.lua | 12 + 15 files changed, 1009 insertions(+), 1 deletion(-) delete mode 160000 .config/nvim create mode 100644 .config/nvim/.nvimrc create mode 100644 .config/nvim/init.lua create mode 100644 .config/nvim/lazy-lock.json create mode 100644 .config/nvim/lua/lorenz/autoclose.lua create mode 100644 .config/nvim/lua/lorenz/catppuccin.lua create mode 100644 .config/nvim/lua/lorenz/cmp.lua create mode 100644 .config/nvim/lua/lorenz/golsp-config.lua create mode 100644 .config/nvim/lua/lorenz/harpoon.lua create mode 100644 .config/nvim/lua/lorenz/init.lua create mode 100644 .config/nvim/lua/lorenz/kickstart.lua create mode 100644 .config/nvim/lua/lorenz/nvim-tree.lua create mode 100644 .config/nvim/lua/lorenz/remap.lua create mode 100644 .config/nvim/lua/lorenz/set.lua create mode 100644 .config/nvim/lua/lorenz/undotree.lua diff --git a/.config/nvim b/.config/nvim deleted file mode 160000 index 611bebe..0000000 --- a/.config/nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 611bebeef3622a12199767e900f957bf717ba5bf diff --git a/.config/nvim/.nvimrc b/.config/nvim/.nvimrc new file mode 100644 index 0000000..d4798e7 --- /dev/null +++ b/.config/nvim/.nvimrc @@ -0,0 +1,146 @@ +version 6.0 +let s:cpo_save=&cpo +set cpo&vim +inoremap lua require("which-key").show("\18", {mode = "i", auto = true}) +cnoremap lua require("which-key").show("\18", {mode = "c", auto = true}) +cnoremap (TelescopeFuzzyCommandSearch) e "lua require('telescope.builtin').command_history { default_text = [=[" . escape(getcmdline(), '"') . "]=] }"  +inoremap u +inoremap u +nnoremap  nohlsearch|diffupdate|normal!   +nnoremap Þ +nnoremap  lua require("which-key").show("\23", {mode = "n", auto = true}) +nnoremap  gÞ +nnoremap  sÞ +nnoremap  Þ +vnoremap  +nnoremap  lua require("which-key").show(" ", {mode = "n", auto = true}) +nnoremap !iÞ +nnoremap !aÞ +nnoremap +nnoremap ! lua require("which-key").show("!", {mode = "n", auto = true}) +nnoremap " lua require("which-key").show("\"", {mode = "n", auto = true}) +xnoremap " lua require("which-key").show("\"", {mode = "v", auto = true}) +xnoremap # y?\V" +omap % (MatchitOperationForward) +xmap % (MatchitVisualForward) +nmap % (MatchitNormalForward) +nnoremap & :&& +nnoremap ' lua require("which-key").show("'", {mode = "n", auto = true}) +xnoremap * y/\V" +nnoremap  +nnoremap  +nnoremap <Þ +nnoremap < lua require("which-key").show("<", {mode = "n", auto = true}) +nnoremap >iÞ +nnoremap >aÞ +nnoremap +nnoremap > lua require("which-key").show(">", {mode = "n", auto = true}) +nnoremap Y y$ +nnoremap +nnoremap [ lua require("which-key").show("[", {mode = "n", auto = true}) +xnoremap +xnoremap [ lua require("which-key").show("[", {mode = "v", auto = true}) +omap [% (MatchitOperationMultiBackward) +xmap [% (MatchitVisualMultiBackward) +nmap [% (MatchitNormalMultiBackward) +nnoremap +nnoremap ] lua require("which-key").show("]", {mode = "n", auto = true}) +xnoremap +xnoremap ] lua require("which-key").show("]", {mode = "v", auto = true}) +omap ]% (MatchitOperationMultiForward) +xmap ]% (MatchitVisualMultiForward) +nmap ]% (MatchitNormalMultiForward) +nnoremap ` lua require("which-key").show("`", {mode = "n", auto = true}) +xmap a% (MatchitVisualTextObject) +nnoremap +nnoremap c lua require("which-key").show("c", {mode = "n", auto = true}) +nnoremap ciÞ +nnoremap caÞ +nnoremap +nnoremap d lua require("which-key").show("d", {mode = "n", auto = true}) +nnoremap diÞ +nnoremap daÞ +nnoremap +nnoremap g lua require("which-key").show("g", {mode = "n", auto = true}) +nnoremap g~iÞ +nnoremap g~aÞ +nnoremap g~Þ +nnoremap guiÞ +nnoremap guaÞ +nnoremap guÞ +nnoremap gUiÞ +nnoremap gUaÞ +nnoremap gUÞ +xnoremap +xnoremap g lua require("which-key").show("g", {mode = "v", auto = true}) +xmap gx NetrwBrowseXVis +nmap gx NetrwBrowseX +omap g% (MatchitOperationBackward) +xmap g% (MatchitVisualBackward) +nmap g% (MatchitNormalBackward) +xnoremap gb (comment_toggle_blockwise_visual) +xnoremap gc (comment_toggle_linewise_visual) +nnoremap gb (comment_toggle_blockwise) +nnoremap gc (comment_toggle_linewise) +nnoremap j v:count == 0 ? 'gj' : 'j' +nnoremap k v:count == 0 ? 'gk' : 'k' +nnoremap viÞ +nnoremap vi lua require("which-key").show("vi", {mode = "n", auto = true}) +nnoremap +nnoremap v lua require("which-key").show("v", {mode = "n", auto = true}) +nnoremap vaÞ +nnoremap yiÞ +nnoremap yaÞ +nnoremap +nnoremap y lua require("which-key").show("y", {mode = "n", auto = true}) +nnoremap zfiÞ +nnoremap zfaÞ +nnoremap zfÞ +nnoremap +nnoremap z lua require("which-key").show("z", {mode = "n", auto = true}) +nnoremap Þ +nnoremap lua require("which-key").show("\23", {mode = "n", auto = true}) +xnoremap NetrwBrowseXVis :call netrw#BrowseXVis() +nnoremap NetrwBrowseX :call netrw#BrowseX(netrw#GX(),netrw#CheckIfRemote(netrw#GX())) +xmap (MatchitVisualTextObject) (MatchitVisualMultiBackward)o(MatchitVisualMultiForward) +onoremap (MatchitOperationMultiForward) :call matchit#MultiMatch("W", "o") +onoremap (MatchitOperationMultiBackward) :call matchit#MultiMatch("bW", "o") +xnoremap (MatchitVisualMultiForward) :call matchit#MultiMatch("W", "n") m'gv`` +xnoremap (MatchitVisualMultiBackward) :call matchit#MultiMatch("bW", "n") m'gv`` +nnoremap (MatchitNormalMultiForward) :call matchit#MultiMatch("W", "n") +nnoremap (MatchitNormalMultiBackward) :call matchit#MultiMatch("bW", "n") +onoremap (MatchitOperationBackward) :call matchit#Match_wrapper('',0,'o') +onoremap (MatchitOperationForward) :call matchit#Match_wrapper('',1,'o') +xnoremap (MatchitVisualBackward) :call matchit#Match_wrapper('',0,'v') m'gv`` +xnoremap (MatchitVisualForward) :call matchit#Match_wrapper('',1,'v') :if col("''") != col("$") | exe ":normal! m'" | endif gv`` +nnoremap (MatchitNormalBackward) :call matchit#Match_wrapper('',0,'n') +nnoremap (MatchitNormalForward) :call matchit#Match_wrapper('',1,'n') +nnoremap PlenaryTestFile :lua require('plenary.test_harness').test_file(vim.fn.expand("%:p")) +xnoremap (comment_toggle_blockwise_visual) lua require("Comment.api").locked("toggle.blockwise")(vim.fn.visualmode()) +xnoremap (comment_toggle_linewise_visual) lua require("Comment.api").locked("toggle.linewise")(vim.fn.visualmode()) +nnoremap nohlsearch|diffupdate|normal!   +inoremap  lua require("which-key").show("\18", {mode = "i", auto = true}) +cnoremap  lua require("which-key").show("\18", {mode = "c", auto = true}) +inoremap  u +inoremap  u +let &cpo=s:cpo_save +unlet s:cpo_save +set clipboard=unnamedplus +set completeopt=menuone,noselect +set helplang=en +set nohlsearch +set ignorecase +set noloadplugins +set mouse=a +set packpath=/snap/nvim/2809/usr/share/nvim/runtime +set runtimepath=~/.config/nvim,~/.local/share/nvim/lazy/lazy.nvim,~/.local/share/nvim/lazy/vim-rhubarb,~/.local/share/nvim/lazy/friendly-snippets,~/.local/share/nvim/lazy/cmp-nvim-lsp,~/.local/share/nvim/lazy/cmp_luasnip,~/.local/share/nvim/lazy/LuaSnip,~/.local/share/nvim/lazy/nvim-cmp,~/.local/share/nvim/lazy/telescope-fzf-native.nvim,~/.local/share/nvim/lazy/plenary.nvim,~/.local/share/nvim/lazy/telescope.nvim,~/.local/share/nvim/lazy/neodev.nvim,~/.local/share/nvim/lazy/fidget.nvim,~/.local/share/nvim/lazy/mason-lspconfig.nvim,~/.local/share/nvim/lazy/mason.nvim,~/.local/share/nvim/lazy/nvim-lspconfig,~/.local/share/nvim/lazy/vim-sleuth,~/.local/share/nvim/lazy/gitsigns.nvim,~/.local/share/nvim/lazy/nvim-treesitter-textobjects,~/.local/share/nvim/lazy/nvim-treesitter,~/.local/share/nvim/lazy/lualine.nvim,~/.local/share/nvim/lazy/indent-blankline.nvim,~/.local/share/nvim/lazy/Comment.nvim,~/.local/share/nvim/lazy/which-key.nvim,~/.local/share/nvim/lazy/vim-fugitive,~/.local/share/nvim/lazy/onedark.nvim,/snap/nvim/2809/usr/share/nvim/runtime,/snap/nvim/2809/usr/share/nvim/runtime/pack/dist/opt/matchit,~/.local/state/nvim/lazy/readme,~/.local/share/nvim/lazy/cmp-nvim-lsp/after,~/.local/share/nvim/lazy/cmp_luasnip/after +set shiftwidth=2 +set smartcase +set softtabstop=2 +set statusline=%#Normal# +set termguicolors +set timeoutlen=300 +set undofile +set updatetime=250 +set window=56 +" vim: set ft=vim : diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..34bfe25 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1 @@ +require("lorenz") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..25c021f --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,34 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" }, + "autoclose.nvim": { "branch": "main", "commit": "37e11589aac55b0e8810dc5865f898f9cb36fef6" }, + "catppuccin": { "branch": "main", "commit": "c2034f7b549152e5cc757820426341ea5000bc7a" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "fidget.nvim": { "branch": "main", "commit": "1d1042d418ee8cb70d68f1e38db639844331c093" }, + "friendly-snippets": { "branch": "main", "commit": "b8fae73a479ae0a1c54f5c98fa687ae8a0addc53" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "harpoon": { "branch": "harpoon2", "commit": "a38be6e0dd4c6db66997deab71fc4453ace97f9c" }, + "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2b3d247fce06f53934174f5dfe0362c42d65c00c" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "neodev.nvim": { "branch": "main", "commit": "2793ba3127c2c93ee486b9072a3ef129eeb950cc" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-lspconfig": { "branch": "master", "commit": "ac530dfb97e51d82e3b0a7cddbf7a4a7c4c10ff8" }, + "nvim-tree.lua": { "branch": "master", "commit": "f1b3e6a7eb92da492bd693257367d9256839ed3d" }, + "nvim-treesitter": { "branch": "master", "commit": "d2b4563230bb3564fa3c0f74373b2700d69f28b4" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "8edd5a6d96936bdff23333d3bc177481388839e5" }, + "nvim-web-devicons": { "branch": "master", "commit": "aaec87dbdaa776bfa0a13c8694bec9bcb7454719" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "undotree": { "branch": "master", "commit": "a1758ba9990b7189f601a3a5acdfc8ca3907a700" }, + "vim-devicons": { "branch": "master", "commit": "71f239af28b7214eebb60d4ea5bd040291fb7e33" }, + "vim-fugitive": { "branch": "master", "commit": "f116dcc8e21021e6fbfb6b0a9f8f7b9566d933f4" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "vim-tmux-navigator": { "branch": "master", "commit": "38b1d0402c4600543281dc85b3f51884205674b6" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/.config/nvim/lua/lorenz/autoclose.lua b/.config/nvim/lua/lorenz/autoclose.lua new file mode 100644 index 0000000..a7efe65 --- /dev/null +++ b/.config/nvim/lua/lorenz/autoclose.lua @@ -0,0 +1,7 @@ +require("autoclose").setup({ + keys = { + ["("] = { escape = false, close = true, pair = "()", disabled_filetypes = {} }, + ["{"] = { escape = false, close = true, pair = "{}", disabled_filetypes = {} }, + ["<"] = { escape = false, close = true, pair = "<>", disabled_filetypes = {} }, + }, +}) diff --git a/.config/nvim/lua/lorenz/catppuccin.lua b/.config/nvim/lua/lorenz/catppuccin.lua new file mode 100644 index 0000000..589a236 --- /dev/null +++ b/.config/nvim/lua/lorenz/catppuccin.lua @@ -0,0 +1,49 @@ +require("catppuccin").setup({ + flavour = "mocha", -- latte, frappe, macchiato, mocha + background = { -- :h background + light = "latte", + dark = "mocha", + }, + transparent_background = false, -- disables setting the background color. + show_end_of_buffer = false, -- shows the '~' characters after the end of buffers + term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) + dim_inactive = { + enabled = false, -- dims the background color of inactive window + shade = "dark", + percentage = 0.15, -- percentage of the shade to apply to the inactive window + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + no_underline = false, -- Force no underline + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = { "italic" }, -- Change the style of comments + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + custom_highlights = {}, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + notify = false, + mini = { + enabled = true, + indentscope_color = "", + }, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, +}) + +-- setup must be called before loading +vim.cmd.colorscheme "catppuccin" diff --git a/.config/nvim/lua/lorenz/cmp.lua b/.config/nvim/lua/lorenz/cmp.lua new file mode 100644 index 0000000..e6b305d --- /dev/null +++ b/.config/nvim/lua/lorenz/cmp.lua @@ -0,0 +1,50 @@ +-- [[ Configure nvim-cmp ]] +-- See `:help cmp` +local cmp = require 'cmp' +local luasnip = require 'luasnip' +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { + completeopt = 'menu,menuone,noinsert', + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} diff --git a/.config/nvim/lua/lorenz/golsp-config.lua b/.config/nvim/lua/lorenz/golsp-config.lua new file mode 100644 index 0000000..63af22a --- /dev/null +++ b/.config/nvim/lua/lorenz/golsp-config.lua @@ -0,0 +1,17 @@ +local nvim_lsp = require('lspconfig') +local lastRootPath = nil +local gomodpath = vim.trim(vim.fn.system("go env GOPATH")) .. "/pkg/mod" + +nvim_lsp.gopls.setup({ + root_dir = function(fname) + local fullpath = vim.fn.expand(fname, ":p") + if string.find(fullpath, gomodpath) and lastRootPath ~= nil then + return lastRootPath + end + local root = nvim_lsp.util.root_pattern("go.mod", ".git")(fname) + if root ~= nil then + lastRootPath = root + end + return root + end, +}) diff --git a/.config/nvim/lua/lorenz/harpoon.lua b/.config/nvim/lua/lorenz/harpoon.lua new file mode 100644 index 0000000..16be69e --- /dev/null +++ b/.config/nvim/lua/lorenz/harpoon.lua @@ -0,0 +1,17 @@ +local harpoon = require("harpoon") + +-- REQUIRED +harpoon:setup() +-- REQUIRED + +vim.keymap.set("n", "h", function() harpoon:list():append() end) +vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + +vim.keymap.set("n", "", function() harpoon:list():select(1) end) +vim.keymap.set("n", "", function() harpoon:list():select(2) end) +vim.keymap.set("n", "", function() harpoon:list():select(3) end) +vim.keymap.set("n", "", function() harpoon:list():select(4) end) + +-- Toggle previous & next buffers stored within Harpoon list +vim.keymap.set("n", "", function() harpoon:list():prev() end) +vim.keymap.set("n", "", function() harpoon:list():next() end) diff --git a/.config/nvim/lua/lorenz/init.lua b/.config/nvim/lua/lorenz/init.lua new file mode 100644 index 0000000..75556c5 --- /dev/null +++ b/.config/nvim/lua/lorenz/init.lua @@ -0,0 +1,9 @@ +require("lorenz.remap") +require("lorenz.set") +require("lorenz.kickstart") +require("lorenz.nvim-tree") +require("lorenz.golsp-config") +require("lorenz.autoclose") +require("lorenz.cmp") +require("lorenz.catppuccin") +require("lorenz.harpoon") diff --git a/.config/nvim/lua/lorenz/kickstart.lua b/.config/nvim/lua/lorenz/kickstart.lua new file mode 100644 index 0000000..f297412 --- /dev/null +++ b/.config/nvim/lua/lorenz/kickstart.lua @@ -0,0 +1,576 @@ +--[[ + +===================================================================== +==================== READ THIS BEFORE CONTINUING ==================== +===================================================================== + +Kickstart.nvim is *not* a distribution. + +Kickstart.nvim is a template for your own configuration. + The goal is that you can read every line of code, top-to-bottom, understand + what your configuration is doing, and modify it to suit your needs. + + Once you've done that, you should start exploring, configuring and tinkering to + explore Neovim! + + If you don't know anything about Lua, I recommend taking some time to read through + a guide. One possible example: + - https://learnxinyminutes.com/docs/lua/ + + + And then you can explore or search through `:help lua-guide` + - https://neovim.io/doc/user/lua-guide.html + + +Kickstart Guide: + +I have left several `:help X` comments throughout the init.lua +You should run that command and read that help section for more information. + +In addition, I have some `NOTE:` items throughout the file. +These are for you, the reader to help understand what is happening. Feel free to delete +them once you know what you're doing, but they should serve as a guide for when you +are first encountering a few different constructs in your nvim config. + +I hope you enjoy your Neovim journey, +- TJ + +P.S. You can delete this when you're done too. It's your config now :) +--]] + +-- Set as the leader key +-- See `:help mapleader` +-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- [[ Install `lazy.nvim` plugin manager ]] +-- https://github.com/folke/lazy.nvim +-- `:help lazy.nvim.txt` for more info +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + } +end +vim.opt.rtp:prepend(lazypath) + +-- [[ Configure plugins ]] +-- NOTE: Here is where you install your plugins. +-- You can configure plugins using the `config` key. +-- +-- You can also configure plugins after the setup call, +-- as they will be available in your neovim runtime. +require('lazy').setup({ + -- NOTE: First, some plugins that don't require any configuration + -- autoclose + 'm4xshen/autoclose.nvim', + + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + + -- vim font + 'ryanoasis/vim-devicons', + + -- Git Plugin + { + "tpope/vim-fugitive", + cmd = "Git" + }, + + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + + -- NOTE: This is where your plugins related to LSP can be installed. + -- The configuration is done below. Search for lspconfig to find it below. + { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, + }, + + { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, + }, + + -- Useful plugin to show you pending keybinds. + { 'folke/which-key.nvim', opts = {} }, + + -- Tmux + { + "christoomey/vim-tmux-navigator", + cmd = { + "TmuxNavigateLeft", + "TmuxNavigateDown", + "TmuxNavigateUp", + "TmuxNavigateRight", + "TmuxNavigatePrevious", + }, + keys = { + { "", "TmuxNavigateLeft" }, + { "", "TmuxNavigateDown" }, + { "", "TmuxNavigateUp" }, + { "", "TmuxNavigateRight" }, + { "", "TmuxNavigatePrevious" }, + }, + }, + { + -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }) + + -- don't override the built-in and fugitive keymaps + local gs = package.loaded.gitsigns + vim.keymap.set({ 'n', 'v' }, ']c', function() + if vim.wo.diff then + return ']c' + end + vim.schedule(function() + gs.next_hunk() + end) + return '' + end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' }) + vim.keymap.set({ 'n', 'v' }, '[c', function() + if vim.wo.diff then + return '[c' + end + vim.schedule(function() + gs.prev_hunk() + end) + return '' + end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' }) + end, + }, + }, + + { + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1000, + config = function() + vim.cmd.colorscheme 'catppuccin' + end, + }, + + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" } + }, + + { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = true, + theme = 'onedark', + component_separators = '|', + section_separators = '', + }, + }, + }, + + { + -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help ibl` + main = 'ibl', + opts = {}, + }, + + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + + -- Fuzzy Finder (files, lsp, etc) + { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + }, + + { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + build = ':TSUpdate', + }, + + -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart + -- These are some example plugins that I've included in the kickstart repository. + -- Uncomment any of the lines below to enable them. + -- require 'kickstart.plugins.autoformat', + -- require 'kickstart.plugins.debug', + + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping + -- up-to-date with whatever is in the kickstart repo. + -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. + -- + -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins + -- { import = 'custom.plugins' }, + + { + "nvim-tree/nvim-tree.lua", + version = "*", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("nvim-tree").setup { + on_attach = My_on_attach, + } + end, + }, + + { + "mbbill/undotree", + lazy = false + }, +}, {}) + +-- [[ Setting options ]] +-- See `:help vim.o` +-- NOTE: You can change these options as you wish! + + +-- [[ Basic Keymaps ]] + +-- Keymaps for better default experience +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- [[ Highlight on yank ]] +-- See `:help vim.highlight.on_yank()` +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) + +-- [[ Configure Telescope ]] +-- See `:help telescope` and `:help telescope.setup()` +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, +} + +-- Enable telescope fzf native, if installed +pcall(require('telescope').load_extension, 'fzf') + +-- Telescope live_grep in git root +-- Function to find the git root directory based on the current buffer's path +local function find_git_root() + -- Use the current buffer's path as the starting point for the git search + local current_file = vim.api.nvim_buf_get_name(0) + local current_dir + local cwd = vim.fn.getcwd() + -- If the buffer is not associated with a file, return nil + if current_file == '' then + current_dir = cwd + else + -- Extract the directory from the current file's path + current_dir = vim.fn.fnamemodify(current_file, ':h') + end + + -- Find the Git root directory from the current file's path + local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] + if vim.v.shell_error ~= 0 then + print 'Not a git repository. Searching on current working directory' + return cwd + end + return git_root +end + +-- Custom live_grep function to search in git root +local function live_grep_git_root() + local git_root = find_git_root() + if git_root then + require('telescope.builtin').live_grep { + search_dirs = { git_root }, + } + end +end + +vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) + +-- See `:help telescope.builtin` +vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) +end, { desc = '[/] Fuzzily search in current buffer' }) + +vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) +vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + +-- [[ Configure Treesitter ]] +-- See `:help nvim-treesitter` +-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' +vim.defer_fn(function() + require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'javascript', 'vimdoc', 'vim', 'bash' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = true, + sync_install = false, + ignore_install = {}, + modules = {}, + + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, + } +end, 0) +-- [[ Configure LSP ]] +-- This function gets run when an LSP connects to a particular buffer. +local on_attach = function(_, bufnr) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) +end + +-- document existing key chains +require('which-key').register { + ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, + ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, + ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, + ['h'] = { name = 'More git', _ = 'which_key_ignore' }, + ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, + ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, +} + +-- mason-lspconfig requires that these setup functions are called in this order +-- before setting up the servers. +require('mason').setup() +require('mason-lspconfig').setup() + +-- Enable the following language servers +-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. +-- +-- Add any additional override configuration in the following tables. They will be passed to +-- the `settings` field of the server config. You must look up that documentation yourself. +-- +-- If you want to override the default filetypes that your language server will attach to you can +-- define the property 'filetypes' to the map in question. +local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- tsserver = {}, + -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, +} + +-- Setup neovim lua configuration +require('neodev').setup() + +-- nvim-cmp supports additional completion capabilities, so broadcast that to servers +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +-- Ensure the servers above are installed +local mason_lspconfig = require 'mason-lspconfig' + +mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), +} + +mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + filetypes = (servers[server_name] or {}).filetypes, + } + end, +} + diff --git a/.config/nvim/lua/lorenz/nvim-tree.lua b/.config/nvim/lua/lorenz/nvim-tree.lua new file mode 100644 index 0000000..31b6f8c --- /dev/null +++ b/.config/nvim/lua/lorenz/nvim-tree.lua @@ -0,0 +1,14 @@ + function My_on_attach(bufnr) + local api = require "nvim-tree.api" + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- default mappings + api.config.mappings.default_on_attach(bufnr) + + -- custom mappings + vim.keymap.set('n', '', api.tree.change_root_to_parent, opts('Up')) + vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help')) +end diff --git a/.config/nvim/lua/lorenz/remap.lua b/.config/nvim/lua/lorenz/remap.lua new file mode 100644 index 0000000..c83f4e3 --- /dev/null +++ b/.config/nvim/lua/lorenz/remap.lua @@ -0,0 +1,23 @@ +vim.g.mapleader = " " + +vim.keymap.set('n', 't', 'NvimTreeOpen') +vim.keymap.set('n', 'qt', 'NvimTreeToggle') + +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +vim.keymap.set("n", "y", "\"+y") +vim.keymap.set("v", "y", "\"+y") +vim.keymap.set("n", "Y", "\"+Y") + +vim.keymap.set("n", "", "cnextzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") + +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + +vim.keymap.set("n", "ö", "$") +vim.keymap.set("v", "ö", "$") diff --git a/.config/nvim/lua/lorenz/set.lua b/.config/nvim/lua/lorenz/set.lua new file mode 100644 index 0000000..ab1c6d3 --- /dev/null +++ b/.config/nvim/lua/lorenz/set.lua @@ -0,0 +1,54 @@ +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.smartindent = true + + +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true +vim.wo.wrap = false +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.softtabstop = 2 + +--scroll +vim.opt.scrolloff = 8 + +vim.opt.updatetime = 50 + +-- Set highlight on search +vim.o.hlsearch = false + +-- Make line numbers default +vim.wo.number = true + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.o.clipboard = 'unnamedplus' + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case-insensitive searching UNLESS \C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.wo.signcolumn = 'yes' + +-- Decrease update time +vim.o.updatetime = 250 +vim.o.timeoutlen = 300 + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- NOTE: You should make sure your terminal supports this +vim.o.termguicolors = true diff --git a/.config/nvim/lua/lorenz/undotree.lua b/.config/nvim/lua/lorenz/undotree.lua new file mode 100644 index 0000000..31b798c --- /dev/null +++ b/.config/nvim/lua/lorenz/undotree.lua @@ -0,0 +1,12 @@ +if has("persistent_undo") + let target_path = expand('~/.undodir') + + " create the directory and any parent directories + " if the location does not exist. + if !isdirectory(target_path) + call mkdir(target_path, "p", 0700) + endif + + let &undodir=target_path + set undofile +endif