├── .gitignore ├── images ├── 1.png ├── 2.png └── 3.png ├── lua ├── 3thparty │ └── plugins │ │ ├── init.lua │ │ ├── tabs.lua │ │ ├── git.lua │ │ ├── fidget.lua │ │ ├── navic.lua │ │ ├── colorscheme.lua │ │ ├── colorizer.lua │ │ ├── maximize.lua │ │ ├── neoscroll.lua │ │ ├── indent-blankline.lua │ │ ├── refactoring.lua │ │ ├── harpoon.lua │ │ ├── toggleterm.lua │ │ ├── lualine.lua │ │ ├── which-key.lua │ │ ├── copilot.lua │ │ ├── autosession.lua │ │ ├── tmux.lua │ │ ├── bufferline.lua │ │ ├── fzf.lua │ │ ├── alpha.lua │ │ ├── neo-tree.lua │ │ └── lsp.lua ├── lazy-bootstrap.lua ├── personal │ ├── colors.lua │ ├── options.lua │ ├── keymaps.lua │ ├── ui.lua │ └── autocommands.lua ├── lazy-plugins.lua ├── lsp │ ├── cmp-setup.lua │ ├── treesitter-setup.lua │ ├── telescope-setup.lua │ └── lsp-setup.lua ├── utils │ ├── duplicates.lua │ ├── remaps.lua │ └── functions.lua └── custom │ └── plugins │ ├── autoformat.lua │ └── debug.lua ├── .stylua.toml ├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── LICENSE.md ├── init.lua ├── README.md └── lazy-lock.json /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | test.sh 3 | .luarc.json 4 | nvim 5 | -------------------------------------------------------------------------------- /images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arturgoms/nvim/HEAD/images/1.png -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arturgoms/nvim/HEAD/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arturgoms/nvim/HEAD/images/3.png -------------------------------------------------------------------------------- /lua/3thparty/plugins/init.lua: -------------------------------------------------------------------------------- 1 | -- You can add your own plugins here or in other files in this directory! 2 | -- 3 | return {} 4 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/tabs.lua: -------------------------------------------------------------------------------- 1 | return { 2 | -- Detect tabstop and shiftwidth automatically 3 | 'tpope/vim-sleuth', 4 | } 5 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/git.lua: -------------------------------------------------------------------------------- 1 | return { 2 | -- Git related plugins 3 | 'tpope/vim-fugitive', 4 | 'tpope/vim-rhubarb', 5 | } 6 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/fidget.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "j-hui/fidget.nvim", 3 | config = function() 4 | require('fidget').setup() 5 | end 6 | } 7 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/navic.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "SmiteshP/nvim-navic", 4 | dependencies = { "neovim/nvim-lspconfig" }, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /.stylua.toml: -------------------------------------------------------------------------------- 1 | column_width = 160 2 | line_endings = "Unix" 3 | indent_type = "Spaces" 4 | indent_width = 2 5 | quote_style = "AutoPreferSingle" 6 | call_parentheses = "None" 7 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/colorscheme.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "arturgoms/moonbow.nvim", 4 | priority = 1000, 5 | config = function() 6 | vim.cmd.colorscheme 'moonbow' 7 | end 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/colorizer.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "brenoprata10/nvim-highlight-colors", 3 | event = "VeryLazy", 4 | config = function() 5 | local c = require("nvim-highlight-colors") 6 | c.setup({}) 7 | end, 8 | } 9 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/maximize.lua: -------------------------------------------------------------------------------- 1 | return { 2 | -- Maximize splits 3 | "szw/vim-maximizer", 4 | config = function() 5 | local r = require("utils.remaps") 6 | r.noremap("n", "m", ":MaximizerToggle!", "maximize split") 7 | end 8 | } 9 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/neoscroll.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "karb94/neoscroll.nvim", 3 | config = function() 4 | require("neoscroll").setup({ 5 | stop_eof = true, 6 | easing_function = "sine", 7 | }) 8 | end, 9 | } 10 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/indent-blankline.lua: -------------------------------------------------------------------------------- 1 | return { 2 | -- Add indentation guides even on blank lines 3 | 'lukas-reineke/indent-blankline.nvim', 4 | -- Enable `lukas-reineke/indent-blankline.nvim` 5 | -- See `:help ibl` 6 | main = 'ibl', 7 | opts = {}, 8 | } 9 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/refactoring.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "ThePrimeagen/refactoring.nvim", 3 | dependencies = { 4 | { "nvim-lua/plenary.nvim" }, 5 | { "nvim-treesitter/nvim-treesitter" } 6 | }, 7 | config = function() 8 | require("refactoring").setup({}) 9 | end 10 | } 11 | -------------------------------------------------------------------------------- /lua/lazy-bootstrap.lua: -------------------------------------------------------------------------------- 1 | -- [[ Install `lazy.nvim` plugin manager ]] 2 | -- https://github.com/folke/lazy.nvim 3 | -- `:help lazy.nvim.txt` for more info 4 | local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' 5 | if not vim.loop.fs_stat(lazypath) then 6 | vim.fn.system { 7 | 'git', 8 | 'clone', 9 | '--filter=blob:none', 10 | 'https://github.com/folke/lazy.nvim.git', 11 | '--branch=stable', -- latest stable release 12 | lazypath, 13 | } 14 | end 15 | vim.opt.rtp:prepend(lazypath) 16 | 17 | -- vim: ts=2 sts=2 sw=2 et 18 | -------------------------------------------------------------------------------- /lua/personal/colors.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local colors = { 4 | fg = "#76787d", 5 | bg = "#252829", 6 | black = '#161616', 7 | white = '#fafafa', 8 | red = '#ee5396', 9 | green = '#08bdba', 10 | blue = '#78a9ff', 11 | yellow = '#ffab91', 12 | orange = '#ffab91', 13 | gray = '#37474F', 14 | darkgray = '#1A1C23', 15 | lightgray = '#2e303e', 16 | inactivegray = '#1C1E26', 17 | purple = '#673ab7', 18 | lightpurple = '#be95ff', 19 | cyan = '#78a9ff', 20 | } 21 | 22 | M.colors = colors 23 | 24 | return M 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | ## Describe the bug 13 | 14 | 15 | ## To Reproduce 16 | 17 | 1. ... 18 | 19 | ## Desktop 20 | 21 | - OS: 22 | - Terminal: 23 | 24 | ## Neovim Version 25 | 26 | 27 | ``` 28 | ``` 29 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/harpoon.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "ThePrimeagen/harpoon", 4 | branch = "harpoon2", 5 | requires = { { "nvim-lua/plenary.nvim" } }, 6 | config = function() 7 | local status_ok, harpoon = pcall(require, "harpoon") 8 | if not status_ok then 9 | return 10 | end 11 | harpoon:setup({}) 12 | 13 | local status_ok, telescope = pcall(require, "telescope") 14 | if not status_ok then 15 | return 16 | end 17 | telescope.load_extension("harpoon") 18 | end, 19 | }, 20 | { 21 | "letieu/harpoon-lualine", 22 | dependencies = { 23 | { 24 | "ThePrimeagen/harpoon", 25 | branch = "harpoon2", 26 | } 27 | }, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/toggleterm.lua: -------------------------------------------------------------------------------- 1 | return { 2 | 'akinsho/toggleterm.nvim', 3 | version = "*", 4 | config = function() 5 | require("toggleterm").setup({ 6 | size = 20, 7 | open_mapping = [[]], 8 | shade_filetypes = {}, 9 | shade_terminals = true, 10 | shading_factor = 2, 11 | start_in_insert = true, 12 | persist_size = false, 13 | direction = "float", 14 | close_on_exit = true, 15 | shell = vim.o.shell, 16 | float_opts = { 17 | border = "curved", 18 | winblend = 0, 19 | highlights = { 20 | border = "Normal", 21 | background = "Normal", 22 | }, 23 | }, 24 | }) 25 | local r = require("utils.remaps") 26 | r.noremap("n", "t", "ToggleTerm direction=float", "Toggle terminal") 27 | end, 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | -- Set as the leader key 2 | -- See `:help mapleader` 3 | -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) 4 | vim.g.mapleader = ' ' 5 | vim.g.maplocalleader = ' ' 6 | 7 | -- [[ Install `lazy.nvim` plugin manager ]] 8 | require('lazy-bootstrap') 9 | 10 | -- [[ Configure plugins ]] 11 | require('lazy-plugins') 12 | 13 | -- [[ Setting options ]] 14 | require('personal.options') 15 | 16 | -- [[ Basic Keymaps ]] 17 | require('personal.keymaps') 18 | 19 | -- [[ Configure Telescope ]] 20 | -- (fuzzy finder) 21 | require('lsp.telescope-setup') 22 | 23 | -- [[ Configure Treesitter ]] 24 | -- (syntax parser for highlighting) 25 | require('lsp.treesitter-setup') 26 | 27 | -- [[ Configure LSP ]] 28 | -- (Language Server Protocol) 29 | require('lsp.lsp-setup') 30 | 31 | -- [[ Configure nvim-cmp ]] 32 | -- (completion) 33 | require('lsp.cmp-setup') 34 | 35 | -- [[ Configure ui ]] 36 | require("personal.ui") 37 | 38 | -- [[ Configure autocommands ]] 39 | require("personal.autocommands") 40 | 41 | -- The line beneath this is called `modeline`. See `:help modeline` 42 | -- vim: ts=2 sts=2 sw=2 et 43 | -------------------------------------------------------------------------------- /lua/personal/options.lua: -------------------------------------------------------------------------------- 1 | -- [[ Setting options ]] 2 | -- See `:help vim.o` 3 | -- NOTE: You can change these options as you wish! 4 | 5 | -- Set highlight on search 6 | vim.o.hlsearch = false 7 | 8 | -- Make line numbers default 9 | vim.wo.number = true 10 | 11 | -- Enable mouse mode 12 | vim.o.mouse = 'a' 13 | 14 | -- Sync clipboard between OS and Neovim. 15 | -- Remove this option if you want your OS clipboard to remain independent. 16 | -- See `:help 'clipboard'` 17 | vim.o.clipboard = 'unnamedplus' 18 | 19 | -- Enable break indent 20 | vim.o.breakindent = true 21 | 22 | -- Save undo history 23 | vim.o.undofile = true 24 | 25 | -- Case-insensitive searching UNLESS \C or capital in search 26 | vim.o.ignorecase = true 27 | vim.o.smartcase = true 28 | 29 | -- Keep signcolumn on by default 30 | vim.wo.signcolumn = 'yes' 31 | 32 | -- Decrease update time 33 | vim.o.updatetime = 250 34 | vim.o.timeoutlen = 300 35 | 36 | -- Set completeopt to have a better completion experience 37 | vim.o.completeopt = 'menuone,noselect' 38 | 39 | -- NOTE: You should make sure your terminal supports this 40 | vim.o.termguicolors = true 41 | 42 | vim.o.relativenumber = true 43 | vim.o.laststatus = 3 44 | -- vim: ts=2 sts=2 sw=2 et 45 | -------------------------------------------------------------------------------- /lua/lazy-plugins.lua: -------------------------------------------------------------------------------- 1 | -- [[ Configure plugins ]] 2 | -- NOTE: Here is where you install your plugins. 3 | -- You can configure plugins using the `config` key. 4 | -- 5 | -- You can also configure plugins after the setup call, 6 | -- as they will be available in your neovim runtime. 7 | require('lazy').setup({ 8 | 9 | -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for custom 10 | -- These are some example plugins that I've included in the custom repository. 11 | -- Uncomment any of the lines below to enable them. 12 | require 'custom.plugins.autoformat', 13 | require 'custom.plugins.debug', 14 | 15 | -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` 16 | -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping 17 | -- up-to-date with whatever is in the 3thparty repo. 18 | -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. 19 | -- 20 | -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins 21 | { import = '3thparty.plugins' }, 22 | }, {}) 23 | 24 | -- vim: ts=2 sts=2 sw=2 et 25 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/lualine.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "nvim-lualine/lualine.nvim", 3 | enabled = true, 4 | lazy = false, 5 | event = { "BufReadPost", "BufNewFile", "VeryLazy" }, 6 | config = function() 7 | require('lualine').setup { 8 | options = { 9 | icons_enabled = true, 10 | theme = 'moonbow', 11 | component_separators = { left = ' ', right = ' ' }, 12 | section_separators = { left = '', right = '' }, 13 | disabled_filetypes = { 14 | statusline = {}, 15 | winbar = {}, 16 | }, 17 | ignore_focus = {}, 18 | always_divide_middle = true, 19 | globalstatus = false, 20 | refresh = { 21 | statusline = 1000, 22 | tabline = 1000, 23 | winbar = 1000, 24 | } 25 | }, 26 | sections = { 27 | lualine_a = { 'mode' }, 28 | lualine_b = { 'branch', 'diff', 'diagnostics' }, 29 | lualine_c = { 'filename', 'harpoon2' }, 30 | lualine_x = { 'encoding', 'fileformat', 'filetype' }, 31 | lualine_y = { 'progress' }, 32 | lualine_z = { 'location' } 33 | }, 34 | inactive_sections = { 35 | lualine_a = {}, 36 | lualine_b = {}, 37 | lualine_c = { 'filename' }, 38 | lualine_x = { 'location' }, 39 | lualine_y = {}, 40 | lualine_z = {} 41 | }, 42 | tabline = {}, 43 | winbar = {}, 44 | inactive_winbar = {}, 45 | extensions = {} 46 | } 47 | end, 48 | } 49 | -------------------------------------------------------------------------------- /lua/lsp/cmp-setup.lua: -------------------------------------------------------------------------------- 1 | -- [[ Configure nvim-cmp ]] 2 | -- See `:help cmp` 3 | local cmp = require 'cmp' 4 | -- local luasnip = require 'luasnip' 5 | --luasnip.config.setup {} 6 | 7 | cmp.setup { 8 | snippet = { 9 | expand = function(args) 10 | -- luasnip.lsp_expand(args.body) 11 | end, 12 | }, 13 | completion = { 14 | completeopt = 'menu,menuone,noinsert' 15 | }, 16 | mapping = cmp.mapping.preset.insert { 17 | [''] = cmp.mapping.select_next_item(), 18 | [''] = cmp.mapping.select_prev_item(), 19 | [''] = cmp.mapping.scroll_docs(-4), 20 | [''] = cmp.mapping.scroll_docs(4), 21 | [''] = cmp.mapping.complete {}, 22 | [''] = cmp.mapping.confirm { 23 | behavior = cmp.ConfirmBehavior.Replace, 24 | select = true, 25 | }, 26 | [''] = cmp.mapping(function(fallback) 27 | if cmp.visible() then 28 | cmp.select_next_item() 29 | -- elseif luasnip.expand_or_locally_jumpable() then 30 | -- luasnip.expand_or_jump() 31 | else 32 | fallback() 33 | end 34 | end, { 'i', 's' }), 35 | [''] = cmp.mapping(function(fallback) 36 | if cmp.visible() then 37 | cmp.select_prev_item() 38 | -- elseif luasnip.locally_jumpable(-1) then 39 | -- luasnip.jump(-1) 40 | else 41 | fallback() 42 | end 43 | end, { 'i', 's' }), 44 | }, 45 | sources = { 46 | { name = 'nvim_lsp' }, 47 | -- { name = 'luasnip' }, 48 | { name = 'path' }, 49 | }, 50 | } 51 | 52 | -- vim: ts=2 sts=2 sw=2 et 53 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/which-key.lua: -------------------------------------------------------------------------------- 1 | -- Useful plugin to show you pending keybinds. 2 | return { 3 | "folke/which-key.nvim", 4 | keys = { "" }, 5 | config = function() 6 | local which_key = require("which-key") 7 | which_key.setup({ 8 | plugins = { 9 | spelling = { 10 | enabled = true, 11 | suggestions = 20, 12 | }, 13 | }, 14 | window = { 15 | border = "shadow", 16 | position = "bottom", 17 | margin = { 0, 1, 1, 5 }, 18 | padding = { 1, 2, 1, 2 }, 19 | }, 20 | triggers_nowait = { 21 | "`", 22 | "'", 23 | "g`", 24 | "g'", 25 | '"', 26 | "", 27 | "z=", 28 | }, 29 | }) 30 | 31 | local opts = { 32 | prefix = "", 33 | } 34 | 35 | local groups = { 36 | n = { name = "fzf" }, 37 | S = { name = "Session" }, 38 | } 39 | 40 | which_key.register(groups, opts) 41 | end, 42 | } 43 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/copilot.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "zbirenbaum/copilot.lua", 4 | enabled = true, 5 | cmd = "Copilot", 6 | event = "InsertEnter", 7 | config = function() 8 | require("copilot").setup({ 9 | panel = { 10 | enabled = true, 11 | auto_refresh = true, 12 | keymap = { 13 | jump_next = "", 14 | jump_prev = "", 15 | accept = "", 16 | refresh = "r", 17 | open = "", 18 | }, 19 | layout = { 20 | position = "bottom", -- | top | left | right 21 | ratio = 0.4, 22 | }, 23 | }, 24 | suggestion = { 25 | enabled = true, 26 | auto_trigger = true, 27 | debounce = 75, 28 | keymap = { 29 | accept = "", 30 | accept_word = false, 31 | accept_line = false, 32 | next = "", 33 | prev = "", 34 | dismiss = "", 35 | }, 36 | }, 37 | }) 38 | end 39 | }, 40 | { 41 | "zbirenbaum/copilot-cmp", 42 | after = { "copilot.lua" }, 43 | config = function() 44 | require("copilot_cmp").setup() 45 | end, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/autosession.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "rmagatti/auto-session", 3 | lazy = false, 4 | config = function() 5 | local auto_session = require("auto-session") 6 | local r = require("utils.remaps") 7 | local function close_neo_tree() 8 | require("neo-tree.sources.manager").close_all() 9 | -- vim.cmd("Vista!") 10 | end 11 | 12 | local function open_neo_tree() 13 | require("neo-tree.sources.manager").show("filesystem") 14 | -- vim.cmd("Vista!!") 15 | end 16 | local opts = { 17 | log_level = "info", 18 | auto_session_enable_last_session = false, 19 | auto_session_root_dir = vim.fn.stdpath("data") .. "/sessions/", 20 | auto_session_enabled = true, 21 | auto_save_enabled = nil, 22 | auto_restore_enabled = nil, 23 | auto_session_suppress_dirs = { os.getenv("HOME") }, 24 | auto_session_use_git_branch = nil, 25 | -- the configs below are lua only 26 | bypass_session_save_file_types = { "alpha" }, 27 | pre_save_cmds = { 28 | close_neo_tree, 29 | }, 30 | post_restore_cmds = { 31 | open_neo_tree, 32 | }, 33 | } 34 | 35 | vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" 36 | 37 | r.noremap("n", "Ss", "SessionSave", "Save") 38 | r.noremap("n", "Sr", "SessionRestore", "Restore") 39 | r.noremap("n", ".", "SessionRestore", "Restore Session") 40 | r.noremap("n", "Sx", "SessionDelete", "Delete") 41 | r.noremap("n", "Sf", "Autosession search", "Searh Session") 42 | r.noremap("n", "Sd", "Autosession delete", "Searh and Delete") 43 | auto_session.setup(opts) 44 | end 45 | } 46 | -------------------------------------------------------------------------------- /lua/utils/duplicates.lua: -------------------------------------------------------------------------------- 1 | local functions = require("utils.functions") 2 | 3 | local X = {} 4 | 5 | local duplicates_n = {} 6 | local duplicates_v = {} 7 | local duplicates_i = {} 8 | local duplicates_s = {} 9 | local duplicates_x = {} 10 | 11 | local function check_and_set_duplicates(input, description, check, table) 12 | if check then 13 | local found = table[input] 14 | 15 | if found ~= nil then 16 | if found ~= description then 17 | print(input .. " already mapped (" .. found .. " so we cannot re-map (" .. description .. ")") 18 | end 19 | end 20 | 21 | table[input] = description 22 | end 23 | end 24 | 25 | X.check_duplicates = function(type, input, description) 26 | local check_n = false 27 | local check_v = false 28 | local check_i = false 29 | local check_s = false 30 | local check_x = false 31 | 32 | if functions.is_table(type) then 33 | if type["n"] then 34 | check_n = true 35 | end 36 | if type["v"] then 37 | check_v = true 38 | end 39 | if type["i"] then 40 | check_i = true 41 | end 42 | if type["s"] then 43 | check_s = true 44 | end 45 | if type["x"] then 46 | check_x = true 47 | end 48 | else 49 | if type == "n" then 50 | check_n = true 51 | end 52 | if type == "v" then 53 | check_v = true 54 | end 55 | if type == "i" then 56 | check_i = true 57 | end 58 | if type == "s" then 59 | check_s = true 60 | end 61 | if type == "x" then 62 | check_x = true 63 | end 64 | end 65 | 66 | check_and_set_duplicates(input, description, check_n, duplicates_n) 67 | check_and_set_duplicates(input, description, check_v, duplicates_v) 68 | check_and_set_duplicates(input, description, check_i, duplicates_i) 69 | check_and_set_duplicates(input, description, check_s, duplicates_s) 70 | check_and_set_duplicates(input, description, check_x, duplicates_x) 71 | end 72 | 73 | return X 74 | -------------------------------------------------------------------------------- /lua/utils/remaps.lua: -------------------------------------------------------------------------------- 1 | local keymap = vim.keymap 2 | local check_duplicates = require("utils.duplicates").check_duplicates 3 | 4 | local X = {} 5 | 6 | local which_key_lazy_registers = nil 7 | local function lazy_register_which_key(input, description) 8 | if which_key_lazy_registers == nil then 9 | which_key_lazy_registers = {} 10 | end 11 | 12 | which_key_lazy_registers[input] = description 13 | end 14 | 15 | local function try_add_to_which_key_by_input(input, description) 16 | local present_which_key, which_key = pcall(require, "which-key") 17 | 18 | local has_leader = string.find(input, "") 19 | if has_leader then 20 | if present_which_key then 21 | if which_key_lazy_registers ~= nil then 22 | which_key.register(which_key_lazy_registers) 23 | which_key_lazy_registers = nil 24 | end 25 | which_key.register({ 26 | [input] = description, 27 | }) 28 | else 29 | lazy_register_which_key(input, description) 30 | end 31 | end 32 | end 33 | 34 | function X.map(type, input, output, description, additional_options) 35 | local options = { remap = true, desc = description } 36 | if additional_options then 37 | options = vim.tbl_deep_extend("force", options, additional_options) 38 | end 39 | keymap.set(type, input, output, options) 40 | check_duplicates(type, input, description) 41 | end 42 | 43 | function X.noremap(type, input, output, description, additional_options) 44 | local options = { remap = false } 45 | if additional_options then 46 | options = vim.tbl_deep_extend("force", options, additional_options) 47 | end 48 | X.map(type, input, output, description, options) 49 | end 50 | 51 | function X.map_virtual(input, description) 52 | check_duplicates(type, input, description) 53 | try_add_to_which_key_by_input(input, description) 54 | end 55 | 56 | function X.which_key(input, description) 57 | try_add_to_which_key_by_input(input, description) 58 | end 59 | 60 | return X 61 | -------------------------------------------------------------------------------- /lua/personal/keymaps.lua: -------------------------------------------------------------------------------- 1 | -- [[ Basic Keymaps ]] 2 | local opts = { noremap = true, silent = true } 3 | 4 | -- Keymaps for better default experience 5 | -- See `:help vim.keymap.set()` 6 | vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) 7 | 8 | -- Remap for dealing with word wrap 9 | vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) 10 | vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) 11 | 12 | -- Diagnostic keymaps 13 | vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) 14 | vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) 15 | vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) 16 | vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) 17 | 18 | -- [[ Highlight on yank ]] 19 | -- See `:help vim.highlight.on_yank()` 20 | local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) 21 | vim.api.nvim_create_autocmd('TextYankPost', { 22 | callback = function() 23 | vim.highlight.on_yank() 24 | end, 25 | group = highlight_group, 26 | pattern = '*', 27 | }) 28 | 29 | -- better indenting 30 | vim.keymap.set("v", "<", "", ">gv") 32 | 33 | -- paste over currently selected text without yanking it 34 | vim.keymap.set("v", "P", '"_dp') 35 | vim.keymap.set("v", "p", '"_dP') 36 | 37 | -- Exit on jj and jk 38 | vim.keymap.set("i", "jj", "", opts) 39 | vim.keymap.set("i", "jk", "", opts) 40 | 41 | -- Fast saving 42 | vim.keymap.set("n", "w", ":write!", opts) 43 | vim.keymap.set("n", "q", ":q!", opts) 44 | 45 | -- Map enter to ciw in normal mode 46 | vim.keymap.set("n", "", "ciw", opts) 47 | 48 | -- Move between windows 49 | vim.keymap.set("n", "", "", opts) 50 | vim.keymap.set("n", "", "", opts) 51 | 52 | -- vim: ts=2 sts=2 sw=2 et 53 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/tmux.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "aserowy/tmux.nvim", 3 | event = "VeryLazy", 4 | config = function() 5 | local tmux = require("tmux") 6 | local r = require("utils.remaps") 7 | tmux.setup({ 8 | copy_sync = { 9 | enable = false, 10 | }, 11 | navigation = { 12 | cycle_navigation = false, 13 | enable_default_keybindings = false, 14 | persist_zoom = true, 15 | }, 16 | resize = { 17 | enable_default_keybindings = false, 18 | }, 19 | }) 20 | local zoom = function() 21 | if vim.fn.winnr("$") > 1 then 22 | if vim.g.zoomed ~= nil then 23 | vim.cmd(vim.g.zoom_winrestcmd) 24 | vim.g.zoomed = 0 25 | else 26 | vim.g.zoom_winrestcmd = vim.fn.winrestcmd() 27 | vim.cmd("resize") 28 | vim.cmd("vertical resize") 29 | vim.g.zoomed = 1 30 | end 31 | else 32 | vim.cmd("!tmux resize-pane -Z") 33 | end 34 | end 35 | r.noremap("n", "", tmux.move_left, "tmux focus left") 36 | r.noremap("n", "", tmux.move_bottom, "tmux focus bottom") 37 | r.noremap("n", "", tmux.move_top, "tmux focus top") 38 | r.noremap("n", "", tmux.move_right, "tmux focus right") 39 | r.noremap("n", "", tmux.resize_left, "tmux resize left") 40 | r.noremap("n", "", tmux.resize_bottom, "tmux resize bottom") 41 | r.noremap("n", "", tmux.resize_top, "tmux resize top") 42 | r.noremap("n", "", tmux.resize_right, "tmux resize right") 43 | r.noremap("t", "", tmux.move_left, "tmux focus left") 44 | r.noremap("t", "", tmux.move_bottom, "tmux focus bottom") 45 | r.noremap("t", "", tmux.move_top, "tmux focus top") 46 | r.noremap("t", "", tmux.move_right, "tmux focus right") 47 | r.noremap("t", "", tmux.resize_left, "tmux resize left") 48 | r.noremap("t", "", tmux.resize_bottom, "tmux resize bottom") 49 | r.noremap("t", "", tmux.resize_top, "tmux resize top") 50 | r.noremap("t", "", tmux.resize_right, "tmux resize right") 51 | r.noremap("n", "z", zoom, "tmux zoom") 52 | end, 53 | } 54 | -------------------------------------------------------------------------------- /lua/lsp/treesitter-setup.lua: -------------------------------------------------------------------------------- 1 | -- [[ Configure Treesitter ]] 2 | -- See `:help nvim-treesitter` 3 | -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' 4 | vim.defer_fn(function() 5 | require('nvim-treesitter.configs').setup { 6 | -- Add languages to be installed here that you want installed for treesitter 7 | ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash', 'elixir' }, 8 | 9 | -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) 10 | auto_install = false, 11 | 12 | highlight = { enable = true }, 13 | indent = { enable = true }, 14 | incremental_selection = { 15 | enable = true, 16 | keymaps = { 17 | init_selection = '', 18 | node_incremental = '', 19 | scope_incremental = '', 20 | node_decremental = '', 21 | }, 22 | }, 23 | textobjects = { 24 | select = { 25 | enable = true, 26 | lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim 27 | keymaps = { 28 | -- You can use the capture groups defined in textobjects.scm 29 | ['aa'] = '@parameter.outer', 30 | ['ia'] = '@parameter.inner', 31 | ['af'] = '@function.outer', 32 | ['if'] = '@function.inner', 33 | ['ac'] = '@class.outer', 34 | ['ic'] = '@class.inner', 35 | }, 36 | }, 37 | move = { 38 | enable = true, 39 | set_jumps = true, -- whether to set jumps in the jumplist 40 | goto_next_start = { 41 | [']m'] = '@function.outer', 42 | [']]'] = '@class.outer', 43 | }, 44 | goto_next_end = { 45 | [']M'] = '@function.outer', 46 | [']['] = '@class.outer', 47 | }, 48 | goto_previous_start = { 49 | ['[m'] = '@function.outer', 50 | ['[['] = '@class.outer', 51 | }, 52 | goto_previous_end = { 53 | ['[M'] = '@function.outer', 54 | ['[]'] = '@class.outer', 55 | }, 56 | }, 57 | swap = { 58 | enable = true, 59 | swap_next = { 60 | ['a'] = '@parameter.inner', 61 | }, 62 | swap_previous = { 63 | ['A'] = '@parameter.inner', 64 | }, 65 | }, 66 | }, 67 | } 68 | end, 0) 69 | 70 | -- vim: ts=2 sts=2 sw=2 et 71 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/bufferline.lua: -------------------------------------------------------------------------------- 1 | local colors = require("personal.colors").colors 2 | return { 3 | "akinsho/bufferline.nvim", 4 | event = "VeryLazy", 5 | version = "*", 6 | dependencies = "nvim-tree/nvim-web-devicons", 7 | config = function() 8 | require("bufferline").setup({ 9 | options = { 10 | always_show_bufferline = true, 11 | indicator = { 12 | icon = " ", 13 | }, 14 | show_close_icon = false, 15 | tab_size = 0, 16 | max_name_length = 25, 17 | offsets = { 18 | { 19 | filetype = "neo-tree", 20 | text = " Project", 21 | highlight = "Directory", 22 | text_align = "left", 23 | }, 24 | }, 25 | modified_icon = "●", 26 | 27 | }, 28 | highlights = { 29 | fill = { 30 | bg = "", 31 | }, 32 | background = { 33 | bg = "", 34 | }, 35 | tab = { 36 | bg = "", 37 | }, 38 | tab_close = { 39 | bg = "", 40 | }, 41 | tab_separator = { 42 | fg = colors.bg, 43 | bg = "", 44 | }, 45 | tab_separator_selected = { 46 | fg = colors.bg, 47 | bg = "", 48 | sp = colors.fg, 49 | }, 50 | close_button = { 51 | bg = "", 52 | fg = colors.fg, 53 | }, 54 | close_button_visible = { 55 | bg = "", 56 | fg = colors.fg, 57 | }, 58 | close_button_selected = { 59 | fg = { attribute = "fg", highlight = "StatusLineNonText" }, 60 | }, 61 | buffer_visible = { 62 | bg = "", 63 | }, 64 | modified = { 65 | bg = "", 66 | }, 67 | modified_visible = { 68 | bg = "", 69 | }, 70 | duplicate = { 71 | fg = colors.fg, 72 | bg = "" 73 | }, 74 | duplicate_visible = { 75 | fg = colors.fg, 76 | bg = "" 77 | }, 78 | separator = { 79 | fg = colors.bg, 80 | bg = "" 81 | }, 82 | separator_selected = { 83 | fg = colors.bg, 84 | bg = "" 85 | }, 86 | separator_visible = { 87 | fg = colors.bg, 88 | bg = "" 89 | }, 90 | offset_separator = { 91 | fg = colors.bg, 92 | bg = "" 93 | }, 94 | }, 95 | }) 96 | end, 97 | } 98 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/fzf.lua: -------------------------------------------------------------------------------- 1 | return { 2 | 'ibhagwan/fzf-lua', 3 | event = "VeryLazy", 4 | requires = { 'nvim-tree/nvim-web-devicons' }, 5 | keys = { 6 | { "nc", function() require("fzf-lua").commands() end, desc = "Search commands" }, 7 | { "nC", function() require("fzf-lua").command_history() end, desc = "Search command history" }, 8 | { "nf", function() require("fzf-lua").files() end, desc = "Find files" }, 9 | { "nt", function() require("fzf-lua").live_grep() end, desc = "Find in files" }, 10 | { "nb", function() require("fzf-lua").grep() end, desc = "Find with regex" }, 11 | { "no", function() require("fzf-lua").oldfiles() end, desc = "Find fi" }, 12 | { "nh", function() require("fzf-lua").highlights() end, desc = "Search highlights" }, 13 | { "nM", function() require("fzf-lua").marks() end, desc = "Search marks" }, 14 | { "nk", function() require("fzf-lua").keymaps() end, desc = "Search keymaps" }, 15 | { "ns", function() require("fzf-lua").spell_suggest() end, desc = "Spell suggestions" }, 16 | { "ngf", function() require("fzf-lua").git_files() end, desc = "Find git files" }, 17 | { "ngb", function() require("fzf-lua").git_branches() end, desc = "Search git branches" }, 18 | { "ngc", function() require("fzf-lua").git_commits() end, desc = "Search git commits" }, 19 | { "ngC", function() require("fzf-lua").git_bcommits() end, desc = "Search git buffer commits" }, 20 | { "nr", function() require("fzf-lua").resume() end, desc = "Resume FZF" }, 21 | { "nlr", function() require("fzf-lua").lsp_references() end, desc = "References" }, 22 | { "nld", function() require("fzf-lua").lsp_definitions() end, desc = "Definitions" }, 23 | { "nle", function() require("fzf-lua").lsp_declarations() end, desc = "Declarations" }, 24 | { "nli", function() require("fzf-lua").lsp_implementations() end, desc = "Implementations" }, 25 | { "nla", function() require("fzf-lua").lsp_code_actions() end, desc = "Code Actions" }, 26 | }, 27 | config = function() 28 | local fzf = require('fzf-lua') 29 | fzf.setup({ 30 | keymap = { 31 | fzf = { 32 | ['CTRL-Q'] = 'select-all+accept', 33 | }, 34 | }, 35 | }) 36 | fzf.register_ui_select() 37 | end, 38 | } 39 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/alpha.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "goolord/alpha-nvim", 3 | enabled = true, 4 | event = "VimEnter", 5 | lazy = true, 6 | opts = function() 7 | local dashboard = require("alpha.themes.dashboard") 8 | local logo = [[ 9 | ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ 10 | ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ 11 | ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ 12 | ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ 13 | ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ 14 | ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ 15 | 16 | ]] 17 | 18 | dashboard.section.header.val = vim.split(logo, "\n") 19 | dashboard.section.buttons.val = { 20 | dashboard.button("f", " " .. " Find file", ":Telescope find_files "), 21 | dashboard.button("n", " " .. " New file", ":ene startinsert "), 22 | dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), 23 | dashboard.button("g", " " .. " Find text", ":Telescope live_grep "), 24 | dashboard.button("c", " " .. " Config", ":e ~/.config/nvim/ "), 25 | dashboard.button("l", "󰒲 " .. " Lazy", ":Lazy"), 26 | dashboard.button("q", " " .. " Quit", ":qa"), 27 | } 28 | for _, button in ipairs(dashboard.section.buttons.val) do 29 | button.opts.hl = "AlphaButtons" 30 | button.opts.hl_shortcut = "AlphaShortcut" 31 | end 32 | dashboard.section.header.opts.hl = "AlphaHeader" 33 | dashboard.section.buttons.opts.hl = "AlphaButtons" 34 | dashboard.section.footer.opts.hl = "AlphaFooter" 35 | dashboard.opts.layout[1].val = 8 36 | return dashboard 37 | end, 38 | config = function(_, dashboard) 39 | -- close Lazy and re-open when the dashboard is ready 40 | if vim.o.filetype == "lazy" then 41 | vim.cmd.close() 42 | vim.api.nvim_create_autocmd("User", { 43 | pattern = "AlphaReady", 44 | callback = function() 45 | require("lazy").show() 46 | end, 47 | }) 48 | end 49 | 50 | require("alpha").setup(dashboard.opts) 51 | 52 | vim.api.nvim_create_autocmd("User", { 53 | pattern = "LazyVimStarted", 54 | callback = function() 55 | local stats = require("lazy").stats() 56 | local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) 57 | dashboard.section.footer.val = "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" 58 | pcall(vim.cmd.AlphaRedraw) 59 | end, 60 | }) 61 | end, 62 | } 63 | -------------------------------------------------------------------------------- /lua/custom/plugins/autoformat.lua: -------------------------------------------------------------------------------- 1 | -- autoformat.lua 2 | -- 3 | -- Use your language server to automatically format your code on save. 4 | -- Adds additional commands as well to manage the behavior 5 | 6 | return { 7 | 'neovim/nvim-lspconfig', 8 | config = function() 9 | -- Switch for controlling whether you want autoformatting. 10 | -- Use :KickstartFormatToggle to toggle autoformatting on or off 11 | local format_is_enabled = true 12 | vim.api.nvim_create_user_command('KickstartFormatToggle', function() 13 | format_is_enabled = not format_is_enabled 14 | print('Setting autoformatting to: ' .. tostring(format_is_enabled)) 15 | end, {}) 16 | 17 | -- Create an augroup that is used for managing our formatting autocmds. 18 | -- We need one augroup per client to make sure that multiple clients 19 | -- can attach to the same buffer without interfering with each other. 20 | local _augroups = {} 21 | local get_augroup = function(client) 22 | if not _augroups[client.id] then 23 | local group_name = 'kickstart-lsp-format-' .. client.name 24 | local id = vim.api.nvim_create_augroup(group_name, { clear = true }) 25 | _augroups[client.id] = id 26 | end 27 | 28 | return _augroups[client.id] 29 | end 30 | 31 | -- Whenever an LSP attaches to a buffer, we will run this function. 32 | -- 33 | -- See `:help LspAttach` for more information about this autocmd event. 34 | vim.api.nvim_create_autocmd('LspAttach', { 35 | group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), 36 | -- This is where we attach the autoformatting for reasonable clients 37 | callback = function(args) 38 | local client_id = args.data.client_id 39 | local client = vim.lsp.get_client_by_id(client_id) 40 | local bufnr = args.buf 41 | 42 | -- Only attach to clients that support document formatting 43 | if not client.server_capabilities.documentFormattingProvider then 44 | return 45 | end 46 | 47 | -- Tsserver usually works poorly. Sorry you work with bad languages 48 | -- You can remove this line if you know what you're doing :) 49 | if client.name == 'tsserver' then 50 | return 51 | end 52 | 53 | -- Create an autocmd that will run *before* we save the buffer. 54 | -- Run the formatting command for the LSP that has just attached. 55 | vim.api.nvim_create_autocmd('BufWritePre', { 56 | group = get_augroup(client), 57 | buffer = bufnr, 58 | callback = function() 59 | if not format_is_enabled then 60 | return 61 | end 62 | 63 | vim.lsp.buf.format { 64 | async = false, 65 | filter = function(c) 66 | return c.id == client.id 67 | end, 68 | } 69 | end, 70 | }) 71 | end, 72 | }) 73 | end, 74 | } 75 | -------------------------------------------------------------------------------- /lua/utils/functions.lua: -------------------------------------------------------------------------------- 1 | local vim = vim 2 | 3 | local X = {} 4 | 5 | ---@param on_attach fun(client, buffer) 6 | function X.on_attach(on_attach) 7 | vim.api.nvim_create_autocmd("LspAttach", { 8 | callback = function(args) 9 | local buffer = args.buf 10 | local client = vim.lsp.get_client_by_id(args.data.client_id) 11 | on_attach(client, buffer) 12 | end, 13 | }) 14 | end 15 | 16 | function X.starts_with(str, start) 17 | return str:sub(1, #start) == start 18 | end 19 | 20 | function X.is_table(to_check) 21 | return type(to_check) == "table" 22 | end 23 | 24 | function X.has_key(t, key) 25 | for t_key, _ in pairs(t) do 26 | if t_key == key then 27 | return true 28 | end 29 | end 30 | return false 31 | end 32 | 33 | function X.has_value(t, val) 34 | for _, value in ipairs(t) do 35 | if value == val then 36 | return true 37 | end 38 | end 39 | return false 40 | end 41 | 42 | function X.tprint(table) 43 | print(vim.inspect(table)) 44 | end 45 | 46 | function X.tprint_keys(table) 47 | for k in pairs(table) do 48 | print(k) 49 | end 50 | end 51 | 52 | X.reload = function() 53 | local presentReload, reload = pcall(require, "plenary.reload") 54 | if presentReload then 55 | local counter = 0 56 | 57 | for moduleName in pairs(package.loaded) do 58 | if X.starts_with(moduleName, "lt.") then 59 | reload.reload_module(moduleName) 60 | counter = counter + 1 61 | end 62 | end 63 | -- clear nvim-mapper keys 64 | vim.g.mapper_records = nil 65 | vim.notify("Reloaded " .. counter .. " modules!") 66 | end 67 | end 68 | 69 | function X.is_macunix() 70 | return vim.fn.has("macunix") 71 | end 72 | 73 | function X.link_highlight(from, to, override) 74 | local hl_exists, _ = pcall(vim.api.nvim_get_hl_by_name, from, false) 75 | if override or not hl_exists then 76 | -- vim.cmd(("highlight link %s %s"):format(from, to)) 77 | vim.api.nvim_set_hl(0, from, { link = to }) 78 | end 79 | end 80 | 81 | X.highlight = function(group, opts) 82 | vim.api.nvim_set_hl(0, group, opts) 83 | end 84 | 85 | X.highlight_bg = function(group, col) 86 | vim.api.nvim_set_hl(0, group, { bg = col }) 87 | end 88 | 89 | -- Define fg color 90 | -- @param group Group 91 | -- @param color Color 92 | X.highlight_fg = function(group, col) 93 | vim.api.nvim_set_hl(0, group, { fg = col }) 94 | end 95 | 96 | -- Define bg and fg color 97 | -- @param group Group 98 | -- @param fgcol Fg Color 99 | -- @param bgcol Bg Color 100 | X.highlight_fg_bg = function(group, fgcol, bgcol) 101 | vim.api.nvim_set_hl(0, group, { bg = bgcol, fg = fgcol }) 102 | end 103 | 104 | X.from_highlight = function(hl) 105 | local result = {} 106 | local list = vim.api.nvim_get_hl_by_name(hl, true) 107 | for k, v in pairs(list) do 108 | local name = k == "background" and "bg" or "fg" 109 | result[name] = string.format("#%06x", v) 110 | end 111 | return result 112 | end 113 | 114 | X.get_color_from_terminal = function(num, default) 115 | local key = "terminal_color_" .. num 116 | return vim.g[key] and vim.g[key] or default 117 | end 118 | 119 | X.cmd = function(name, command, desc) 120 | vim.api.nvim_create_user_command(name, command, desc) 121 | end 122 | 123 | X.autocmd = function(evt, opts) 124 | vim.api.nvim_create_autocmd(evt, opts) 125 | end 126 | return X 127 | -------------------------------------------------------------------------------- /lua/personal/ui.lua: -------------------------------------------------------------------------------- 1 | -- show matching brackets/parenthesis 2 | vim.opt.showmatch = true 3 | 4 | -- disable startup message 5 | vim.opt.shortmess:append("sI") 6 | 7 | -- cmd display (set to zero to autohide) 8 | vim.opt.cmdheight = 1 9 | 10 | -- gutter sizing 11 | vim.opt.signcolumn = "auto:2" 12 | 13 | -- syntax highlighting 14 | vim.opt.termguicolors = true 15 | vim.opt.synmaxcol = 512 16 | 17 | -- show line numbers 18 | vim.opt.number = true 19 | 20 | -- default no line wrapping 21 | vim.opt.wrap = false 22 | 23 | -- set indents when wrapped 24 | vim.opt.breakindent = true 25 | 26 | -- highlight cursor 27 | vim.opt.cursorline = true 28 | -- set cursorcolumn = true 29 | 30 | -- show invisibles 31 | vim.opt.listchars = { tab = " ", trail = "·", extends = "»", precedes = "«", nbsp = "░" } 32 | vim.opt.list = true 33 | 34 | -- split style 35 | vim.opt.splitbelow = true 36 | vim.opt.splitright = true 37 | 38 | -- custom tabline 39 | local noname = "[unnamed]" 40 | 41 | local function extract_filename(win) 42 | local b = vim.api.nvim_win_get_buf(win) 43 | local fullname = vim.api.nvim_buf_get_name(b) 44 | local mod = vim.api.nvim_buf_get_option(b, 'modified') and "◈ " or "" 45 | if fullname ~= "" then 46 | local shortname = vim.fn.fnamemodify(fullname, ":~:.:gs%(.?[^/])[^/]*/%\1/%") 47 | if #shortname > 30 then shortname = vim.fn.fnamemodify(fullname, ":t") end 48 | return mod .. shortname 49 | end 50 | end 51 | 52 | local function get_best_window_filename(tabpage, window) 53 | local filename = extract_filename(window) 54 | if filename == nil then 55 | local wins = vim.api.nvim_tabpage_list_wins(tabpage) 56 | if #wins > 1 then 57 | for _, win in ipairs(wins) do 58 | filename = extract_filename(win) 59 | break 60 | end 61 | end 62 | end 63 | if filename == nil then 64 | return noname 65 | end 66 | return filename 67 | end 68 | 69 | local function is_float_win(win) 70 | local config = vim.api.nvim_win_get_config(win) 71 | return config.zindex and config.zindex > 0 72 | end 73 | 74 | local function getname(tabpage) 75 | -- vim.F.npcall(vim.api.nvim_tabpage_get_var, tabpage, "tab_title") 76 | local title = vim.t[tabpage].tab_title 77 | if title ~= nil then 78 | return title 79 | end 80 | 81 | local window = vim.api.nvim_tabpage_get_win(tabpage) 82 | -- don't replace the last filename-buffer w/ floating windows 83 | if is_float_win(window) then 84 | return vim.t[tabpage].last_buffer_filename 85 | end 86 | 87 | local filename = get_best_window_filename(tabpage, window) 88 | vim.t[tabpage].last_buffer_filename = filename 89 | return filename 90 | end 91 | 92 | function Tabline() 93 | local tl = {} 94 | local current = vim.api.nvim_get_current_tabpage() 95 | for i, tabpage in ipairs(vim.api.nvim_list_tabpages()) do 96 | local hi = tabpage == current and "%#TabLineSel#" or "%#TabLine#" 97 | local hiSep = tabpage == current and "%#TabLineSelSep#" or "%#TabLineSep#" 98 | table.insert(tl, "%" .. i .. "T") -- mouse click target region 99 | table.insert(tl, hi .. " " .. getname(tabpage) .. " ") 100 | table.insert(tl, hiSep .. "▓▒░ " .. hi) 101 | end 102 | table.insert(tl, "%T") -- end mouse click region(s). 103 | table.insert(tl, "%#TabLineFill#") 104 | return table.concat(tl, '') 105 | end 106 | 107 | vim.opt.tabline = [[%!v:lua.Tabline()]] 108 | -------------------------------------------------------------------------------- /lua/lsp/telescope-setup.lua: -------------------------------------------------------------------------------- 1 | -- [[ Configure Telescope ]] 2 | -- See `:help telescope` and `:help telescope.setup()` 3 | require('telescope').setup { 4 | defaults = { 5 | mappings = { 6 | i = { 7 | [''] = false, 8 | [''] = false, 9 | }, 10 | }, 11 | layout_config = { 12 | vertical = { width = 0.5 } 13 | -- other layout configuration here 14 | }, 15 | }, 16 | } 17 | 18 | -- Enable telescope fzf native, if installed 19 | pcall(require('telescope').load_extension, 'fzf') 20 | 21 | -- Telescope live_grep in git root 22 | -- Function to find the git root directory based on the current buffer's path 23 | local function find_git_root() 24 | -- Use the current buffer's path as the starting point for the git search 25 | local current_file = vim.api.nvim_buf_get_name(0) 26 | local current_dir 27 | local cwd = vim.fn.getcwd() 28 | -- If the buffer is not associated with a file, return nil 29 | if current_file == "" then 30 | current_dir = cwd 31 | else 32 | -- Extract the directory from the current file's path 33 | current_dir = vim.fn.fnamemodify(current_file, ":h") 34 | end 35 | 36 | -- Find the Git root directory from the current file's path 37 | local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1] 38 | if vim.v.shell_error ~= 0 then 39 | print("Not a git repository. Searching on current working directory") 40 | return cwd 41 | end 42 | return git_root 43 | end 44 | 45 | -- Custom live_grep function to search in git root 46 | local function live_grep_git_root() 47 | local git_root = find_git_root() 48 | if git_root then 49 | require('telescope.builtin').live_grep({ 50 | search_dirs = {git_root}, 51 | }) 52 | end 53 | end 54 | 55 | vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) 56 | 57 | -- See `:help telescope.builtin` 58 | vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) 59 | vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) 60 | vim.keymap.set('n', '/', function() 61 | -- You can pass additional configuration to telescope to change theme, layout, etc. 62 | require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { 63 | winblend = 10, 64 | previewer = false, 65 | }) 66 | end, { desc = '[/] Fuzzily search in current buffer' }) 67 | 68 | vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) 69 | vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) 70 | vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) 71 | vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) 72 | vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) 73 | vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) 74 | vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) 75 | vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) 76 | 77 | -- vim: ts=2 sts=2 sw=2 et 78 | -------------------------------------------------------------------------------- /lua/custom/plugins/debug.lua: -------------------------------------------------------------------------------- 1 | -- debug.lua 2 | -- 3 | -- Shows how to use the DAP plugin to debug your code. 4 | -- 5 | -- Primarily focused on configuring the debugger for Go, but can 6 | -- be extended to other languages as well. That's why it's called 7 | -- kickstart.nvim and not kitchen-sink.nvim ;) 8 | 9 | return { 10 | -- NOTE: Yes, you can install new plugins here! 11 | 'mfussenegger/nvim-dap', 12 | -- NOTE: And you can specify dependencies as well 13 | dependencies = { 14 | -- Creates a beautiful debugger UI 15 | 'rcarriga/nvim-dap-ui', 16 | 17 | -- Installs the debug adapters for you 18 | 'williamboman/mason.nvim', 19 | 'jay-babu/mason-nvim-dap.nvim', 20 | 21 | -- Add your own debuggers here 22 | 'leoluz/nvim-dap-go', 23 | }, 24 | config = function() 25 | local dap = require 'dap' 26 | local dapui = require 'dapui' 27 | 28 | require('mason-nvim-dap').setup { 29 | -- Makes a best effort to setup the various debuggers with 30 | -- reasonable debug configurations 31 | automatic_setup = true, 32 | 33 | -- You can provide additional configuration to the handlers, 34 | -- see mason-nvim-dap README for more information 35 | handlers = {}, 36 | 37 | -- You'll need to check that you have the required things installed 38 | -- online, please don't ask me how to install them :) 39 | ensure_installed = { 40 | -- Update this to ensure that you have the debuggers for the langs you want 41 | 'delve', 42 | }, 43 | } 44 | 45 | -- Basic debugging keymaps, feel free to change to your liking! 46 | vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) 47 | vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) 48 | vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) 49 | vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) 50 | vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) 51 | vim.keymap.set('n', 'B', function() 52 | dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') 53 | end, { desc = 'Debug: Set Breakpoint' }) 54 | 55 | -- Dap UI setup 56 | -- For more information, see |:help nvim-dap-ui| 57 | dapui.setup { 58 | -- Set icons to characters that are more likely to work in every terminal. 59 | -- Feel free to remove or use ones that you like more! :) 60 | -- Don't feel like these are good choices. 61 | icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, 62 | controls = { 63 | icons = { 64 | pause = '⏸', 65 | play = '▶', 66 | step_into = '⏎', 67 | step_over = '⏭', 68 | step_out = '⏮', 69 | step_back = 'b', 70 | run_last = '▶▶', 71 | terminate = '⏹', 72 | disconnect = '⏏', 73 | }, 74 | }, 75 | } 76 | 77 | -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. 78 | vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) 79 | 80 | dap.listeners.after.event_initialized['dapui_config'] = dapui.open 81 | dap.listeners.before.event_terminated['dapui_config'] = dapui.close 82 | dap.listeners.before.event_exited['dapui_config'] = dapui.close 83 | 84 | -- Install golang specific config 85 | require('dap-go').setup() 86 | end, 87 | } 88 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/neo-tree.lua: -------------------------------------------------------------------------------- 1 | -- references: 2 | -- https://github.com/nvim-neo-tree/neo-tree.nvim 3 | -- https://github.com/nvim-neo-tree/neo-tree.nvim/wiki/Recipes 4 | return { 5 | "nvim-neo-tree/neo-tree.nvim", 6 | dependencies = { 7 | "nvim-lua/plenary.nvim", 8 | "nvim-tree/nvim-web-devicons", 9 | "MunifTanjim/nui.nvim", 10 | }, 11 | event = "VeryLazy", 12 | keys = { 13 | { "e", ":Neotree toggle", silent = true, desc = "File Explorer" }, 14 | }, 15 | config = function() 16 | require("neo-tree").setup({ 17 | close_if_last_window = true, 18 | popup_border_style = "single", 19 | enable_git_status = true, 20 | enable_modified_markers = true, 21 | enable_diagnostics = false, 22 | sort_case_insensitive = true, 23 | source_selector = { 24 | winbar = true, 25 | content_layout = "center", 26 | sources = { 27 | { source = "filesystem", display_name = "  File " }, 28 | { source = "git_status", display_name = "  Git " }, 29 | { source = "buffers", display_name = " ➜ Buffs " }, 30 | }, 31 | }, 32 | default_component_configs = { 33 | indent = { 34 | with_markers = false, 35 | with_expanders = true, 36 | }, 37 | modified = { 38 | symbol = " ", 39 | highlight = "NeoTreeModified", 40 | }, 41 | icon = { 42 | folder_closed = "", 43 | folder_open = "", 44 | folder_empty = "", 45 | folder_empty_open = "", 46 | }, 47 | git_status = { 48 | symbols = { 49 | -- Change type 50 | added = "", 51 | deleted = "", 52 | modified = "", 53 | renamed = "", 54 | -- Status type 55 | untracked = "", 56 | ignored = "", 57 | unstaged = "", 58 | staged = "", 59 | conflict = "", 60 | }, 61 | }, 62 | }, 63 | window = { 64 | position = "left", 65 | width = 35, 66 | mappings = { 67 | ["o"] = "open", 68 | ["v"] = "open_vsplit", 69 | }, 70 | }, 71 | filesystem = { 72 | use_libuv_file_watcher = true, 73 | filtered_items = { 74 | hide_dotfiles = false, 75 | hide_gitignored = false, 76 | hide_by_name = { 77 | "node_modules", 78 | }, 79 | never_show = { 80 | ".DS_Store", 81 | "thumbs.db", 82 | }, 83 | }, 84 | }, 85 | event_handlers = { 86 | { 87 | event = "neo_tree_window_after_open", 88 | handler = function(args) 89 | if args.position == "left" or args.position == "right" then 90 | vim.cmd("wincmd =") 91 | end 92 | end, 93 | }, 94 | { 95 | event = "neo_tree_window_after_close", 96 | handler = function(args) 97 | if args.position == "left" or args.position == "right" then 98 | vim.cmd("wincmd =") 99 | end 100 | end, 101 | }, 102 | { 103 | event = "neo_tree_buffer_enter", 104 | handler = function(_) 105 | vim.opt_local.signcolumn = "auto" 106 | end, 107 | }, 108 | }, 109 | }) 110 | end, 111 | } 112 | -------------------------------------------------------------------------------- /lua/3thparty/plugins/lsp.lua: -------------------------------------------------------------------------------- 1 | return { 2 | -- NOTE: This is where your plugins related to LSP can be installed. 3 | -- The configuration is done below. Search for lspconfig to find it below. 4 | { 5 | -- LSP Configuration & Plugins 6 | 'neovim/nvim-lspconfig', 7 | dependencies = { 8 | -- Automatically install LSPs to stdpath for neovim 9 | 'williamboman/mason.nvim', 10 | 'williamboman/mason-lspconfig.nvim', 11 | 12 | -- Useful status updates for LSP 13 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` 14 | { 'j-hui/fidget.nvim', opts = {} }, 15 | -- Additional lua configuration, makes nvim stuff amazing! 16 | 'folke/neodev.nvim', 17 | }, 18 | }, 19 | 20 | { 21 | -- Autocompletion 22 | 'hrsh7th/nvim-cmp', 23 | dependencies = { 24 | -- Snippet Engine & its associated nvim-cmp source 25 | -- 'L3MON4D3/LuaSnip', 26 | -- 'saadparwaiz1/cmp_luasnip', 27 | 28 | -- Adds LSP completion capabilities 29 | 'hrsh7th/cmp-nvim-lsp', 30 | 31 | -- Adds a number of user-friendly snippets 32 | 'rafamadriz/friendly-snippets', 33 | }, 34 | }, 35 | 36 | -- Useful plugin to show you pending keybinds. 37 | { 38 | -- Adds git related signs to the gutter, as well as utilities for managing changes 39 | 'lewis6991/gitsigns.nvim', 40 | opts = { 41 | -- See `:help gitsigns.txt` 42 | signs = { 43 | add = { text = '+' }, 44 | change = { text = '~' }, 45 | delete = { text = '_' }, 46 | topdelete = { text = '‾' }, 47 | changedelete = { text = '~' }, 48 | }, 49 | on_attach = function(bufnr) 50 | vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }) 51 | 52 | -- don't override the built-in and fugitive keymaps 53 | local gs = package.loaded.gitsigns 54 | vim.keymap.set({ 'n', 'v' }, ']c', function() 55 | if vim.wo.diff then 56 | return ']c' 57 | end 58 | vim.schedule(function() 59 | gs.next_hunk() 60 | end) 61 | return '' 62 | end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' }) 63 | vim.keymap.set({ 'n', 'v' }, '[c', function() 64 | if vim.wo.diff then 65 | return '[c' 66 | end 67 | vim.schedule(function() 68 | gs.prev_hunk() 69 | end) 70 | return '' 71 | end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' }) 72 | end, 73 | }, 74 | }, 75 | 76 | 77 | -- "gc" to comment visual regions/lines 78 | { 'numToStr/Comment.nvim', opts = {} }, 79 | 80 | -- Fuzzy Finder (files, lsp, etc) 81 | { 82 | 'nvim-telescope/telescope.nvim', 83 | branch = '0.1.x', 84 | dependencies = { 85 | 'nvim-lua/plenary.nvim', 86 | -- Fuzzy Finder Algorithm which requires local dependencies to be built. 87 | -- Only load if `make` is available. Make sure you have the system 88 | -- requirements installed. 89 | { 90 | 'nvim-telescope/telescope-fzf-native.nvim', 91 | -- NOTE: If you are having trouble with this installation, 92 | -- refer to the README for telescope-fzf-native for more instructions. 93 | build = 'make', 94 | cond = function() 95 | return vim.fn.executable 'make' == 1 96 | end, 97 | }, 98 | }, 99 | }, 100 | 101 | { 102 | -- Highlight, edit, and navigate code 103 | 'nvim-treesitter/nvim-treesitter', 104 | dependencies = { 105 | 'nvim-treesitter/nvim-treesitter-textobjects', 106 | }, 107 | build = ':TSUpdate', 108 | }, 109 | } 110 | -------------------------------------------------------------------------------- /lua/personal/autocommands.lua: -------------------------------------------------------------------------------- 1 | local api = vim.api 2 | 3 | local colors = { 4 | fg = "#76787d", 5 | bg = "#222222", 6 | } 7 | 8 | -- don't auto comment new line 9 | api.nvim_create_autocmd("BufEnter", { command = [[set formatoptions-=cro]] }) 10 | 11 | --- Remove all trailing whitespace on save 12 | local TrimWhiteSpaceGrp = api.nvim_create_augroup("TrimWhiteSpaceGrp", { clear = true }) 13 | api.nvim_create_autocmd("BufWritePre", { 14 | command = [[:%s/\s\+$//e]], 15 | group = TrimWhiteSpaceGrp, 16 | }) 17 | 18 | -- wrap words "softly" (no carriage return) in mail buffer 19 | api.nvim_create_autocmd("Filetype", { 20 | pattern = "mail", 21 | callback = function() 22 | vim.opt.textwidth = 0 23 | vim.opt.wrapmargin = 0 24 | vim.opt.wrap = true 25 | vim.opt.linebreak = true 26 | vim.opt.columns = 80 27 | vim.opt.colorcolumn = "80" 28 | end, 29 | }) 30 | 31 | -- Highlight on yank 32 | api.nvim_create_autocmd("TextYankPost", { 33 | callback = function() 34 | vim.highlight.on_yank() 35 | end, 36 | }) 37 | 38 | -- go to last loc when opening a buffer 39 | api.nvim_create_autocmd("BufReadPost", { 40 | callback = function() 41 | local mark = vim.api.nvim_buf_get_mark(0, '"') 42 | local lcount = vim.api.nvim_buf_line_count(0) 43 | if mark[1] > 0 and mark[1] <= lcount then 44 | pcall(vim.api.nvim_win_set_cursor, 0, mark) 45 | end 46 | end, 47 | }) 48 | 49 | api.nvim_create_autocmd("FileType", { pattern = "man", command = [[nnoremap q :quit]] }) 50 | 51 | -- show cursor line only in active window 52 | local cursorGrp = api.nvim_create_augroup("CursorLine", { clear = true }) 53 | api.nvim_create_autocmd({ "InsertLeave", "WinEnter" }, { 54 | pattern = "*", 55 | command = "set cursorline", 56 | group = cursorGrp, 57 | }) 58 | api.nvim_create_autocmd( 59 | { "InsertEnter", "WinLeave" }, 60 | { pattern = "*", command = "set nocursorline", group = cursorGrp } 61 | ) 62 | 63 | -- Enable spell checking for certain file types 64 | api.nvim_create_autocmd( 65 | { "BufRead", "BufNewFile" }, 66 | -- { pattern = { "*.txt", "*.md", "*.tex" }, command = [[setlocal spell setlocal spelllang=en,de]] } 67 | { 68 | pattern = { "*.txt", "*.md", "*.tex" }, 69 | callback = function() 70 | vim.opt.spell = true 71 | vim.opt.spelllang = "en,de" 72 | end, 73 | } 74 | ) 75 | 76 | -- Use LspAttach autocommand to only map the following keys 77 | -- after the language server attaches to the current buffer 78 | vim.api.nvim_create_autocmd('LspAttach', { 79 | callback = function(ev) 80 | local opts = { buffer = ev.buf } 81 | vim.keymap.set('n', 'v', "vsplit | lua vim.lsp.buf.definition()", opts) 82 | end, 83 | }) 84 | 85 | -- change the background color of floating windows and borders. 86 | vim.api.nvim_create_autocmd('ColorScheme', { 87 | callback = function() 88 | vim.cmd('highlight NormalFloat guibg=none guifg=none') 89 | vim.cmd('highlight FloatBorder guifg=' .. colors.fg .. ' guibg=none') 90 | vim.cmd('highlight NormalNC guibg=none guifg=none') 91 | end, 92 | }) 93 | 94 | -- close some filetypes with 95 | vim.api.nvim_create_autocmd("FileType", { 96 | group = vim.api.nvim_create_augroup("close_with_q", { clear = true }), 97 | pattern = { 98 | "PlenaryTestPopup", 99 | "help", 100 | "lspinfo", 101 | "man", 102 | "notify", 103 | "qf", 104 | "spectre_panel", 105 | "startuptime", 106 | "tsplayground", 107 | "neotest-output", 108 | "checkhealth", 109 | "neotest-summary", 110 | "neotest-output-panel", 111 | "TelescopePrompt", 112 | }, 113 | callback = function(event) 114 | vim.bo[event.buf].buflisted = false 115 | vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) 116 | end, 117 | }) 118 | 119 | -- resize neovim split when terminal is resized 120 | vim.api.nvim_command('autocmd VimResized * wincmd =') 121 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Showcase 2 | 3 | ![demo1](https://github.com/arturgoms/nvim/blob/v2.0/images/1.png) 4 | ![demo2](https://github.com/arturgoms/nvim/blob/v2.0/images/2.png) 5 | ![demo3](https://github.com/arturgoms/nvim/blob/v2.0/images/3.png) 6 | 7 | ## Disclaimer 8 | A lot of the keybinds will not make much sense if you just try to use it. This is because i'm using a QMK compatible keyboard and a lot of these keybinds 9 | is in a layer in my keyboard. If you wanna understand better you can check out the layer definition here: [Layer](https://github.com/arturgoms/keyboards/blob/main/src/qmk/keyboards/idobao/id75/keymaps/arturgoms/keymap.c), the layout here [Layout](https://github.com/arturgoms/keyboards/blob/main/src/qmk/users/arturgoms/definitions/keymap_blocks.h) and the macros here [Macros](https://github.com/arturgoms/keyboards/blob/e39ecd8037dd40efd1e9938310c34aa21b97ec80/src/qmk/users/arturgoms/features/macros.c#L328) 10 | 11 | I advise you to fork this project if you want to use it, i cannot give you sure that i'll not break this in the future 12 | ## Plugins: 13 | 14 | Not all but the main ones 15 | 16 | - Core 17 | - [Lazy](https://github.com/folke/lazy.nvim) -> Manage Plugins 18 | - [Plenary](https://github.com/nvim-lua/plenary.nvim) -> Dependence for a lot of plugins 19 | - [Neotree](https://github.com/nvim-neo-tree/neo-tree.nvim) -> File Explorer 20 | - [Bufferline](https://github.com/akinsho/bufferline.nvim) -> Show buffers in little tabs 21 | - Appearance 22 | - [Moonbow](https://github.com/arturgoms/moonbow.nvim) -> My Moonbow colorsheme 23 | - [Web Devicons](https://github.com/kyazdani42/nvim-web-devicons) -> Add icons to vim 24 | - [Alpha](https://github.com/goolord/alpha-nvim) -> Dashboard 25 | - Utils 26 | - [Whichkey](https://github.com/folke/which-key.nvim) -> Tools to show keymaps helper 27 | - [Harpoon](https://github.com/ThePrimeagen/harpoon) -> Quick switch between files 28 | - [Bbye](https://github.com/moll/vim-bbye) -> Better way to close buffers 29 | - [Scope](https://github.com/tiagovla/scope.nvim) -> Focus on one tab when creating new ones 30 | - [Maximizer](https://github.com/szw/vim-maximizer) -> Focus on one buffer 31 | - [Surround](https://github.com/kylechui/nvim-surround) -> Surround words with what you want 32 | - [Comment](https://github.com/numToStr/Comment.nvim) -> Comment stuff 33 | - [Telescope](https://github.com/nvim-telescope/telescope.nvim) -> LSP and Helpers 34 | - [Cmp](https://github.com/hrsh7th/nvim-cmp) -> Auto completions 35 | - [Auto Session](https://github.com/rmagatti/auto-session) -> Auto create and restore sessions 36 | 37 | ## Keybinds: 38 | 39 | WIP: but you can hit space to see whichkey 40 | 41 | - Normal/Insert `S-Up` -> Move line 1 to top 42 | - Normal/Insert `S-Down` -> Move line 1 to Botton 43 | - Normal `S-u` -> Open quick menu Harpoon 44 | - Normal `S-l` -> Add harpoon bookmark 45 | - Normal `S-h` -> Go to 1 file in Harpoon 46 | - Normal `S-j` -> Go to 2 file in Harpoon 47 | - Normal `S-a` -> Go to 3 file in Harpoon 48 | - Normal `S-x` -> Go to 4 file in Harpoon 49 | 50 | ## Vim Motions: 51 | 52 | WIP: i keep forgeting these 53 | 54 | - `ciw` -> delete the hole word that the cursor is in 55 | - `yap` -> yank the hole block of code 56 | - `ys` -> surround the word with that char 57 | - `ds` -> delete the surround 58 | - `cs` -> change the surround from some_char to another_char 59 | - `zz` -> put current line on the middle of the screen 60 | - `zt` -> put current line on the top of the screen 61 | - `zb` -> put current line on the bottom of the screen 62 | - `gc` -> toggle inline comment 63 | - `gb` -> toggle inline comment 64 | 65 | ## Install: 66 | 67 | ```shell 68 | mv ~/.config/nvim/ ~/.config/nvim.bak 69 | git clone https://github.com/arturgoms/nvim.git ~/.config/nvim 70 | ``` 71 | ## Credits: 72 | 73 | A lot from here is a combination os things that i did but also a lot from others config. 74 | 75 | - [Lunarvim] 76 | - [AstroNvim] 77 | - [Kickstart Modular](https://github.com/dam9000/kickstart-modular.nvim) 78 | 79 | -------------------------------------------------------------------------------- /lazy-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, 3 | "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, 4 | "auto-session": { "branch": "main", "commit": "29a8c77a0579636d5520aebd38bdbc2e6079f2f5" }, 5 | "bufferline.nvim": { "branch": "main", "commit": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef" }, 6 | "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, 7 | "copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" }, 8 | "copilot.lua": { "branch": "master", "commit": "f7612f5af4a7d7615babf43ab1e67a2d790c13a6" }, 9 | "fidget.nvim": { "branch": "main", "commit": "60404ba67044c6ab01894dd5bf77bd64ea5e09aa" }, 10 | "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, 11 | "fzf-lua": { "branch": "main", "commit": "a1d6608b6ba5309f9abda776398c97fe8ed26c11" }, 12 | "gitsigns.nvim": { "branch": "main", "commit": "4e348641b8206c3b8d23080999e3ddbe4ca90efc" }, 13 | "harpoon": { "branch": "harpoon2", "commit": "a38be6e0dd4c6db66997deab71fc4453ace97f9c" }, 14 | "harpoon-lualine": { "branch": "master", "commit": "1a2b95c62bc74f5645676bd4d3611592e55ecaed" }, 15 | "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, 16 | "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, 17 | "lualine.nvim": { "branch": "master", "commit": "af4c3cf17206810880d2a93562e0a4c0d901c684" }, 18 | "mason-lspconfig.nvim": { "branch": "main", "commit": "1bed24274d911bb3ed730c516ffce27e8fdeeac3" }, 19 | "mason-nvim-dap.nvim": { "branch": "main", "commit": "67210c0e775adec55de9826b038e8b62de554afc" }, 20 | "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, 21 | "moonbow.nvim": { "branch": "master", "commit": "d3bdb22350b03a62868670b2e5d9aef256e380bb" }, 22 | "neo-tree.nvim": { "branch": "main", "commit": "146445f402753c7c7fefe99629588fc1be4c98dd" }, 23 | "neodev.nvim": { "branch": "main", "commit": "84e0290f5600e8b89c0dfcafc864f45496a53400" }, 24 | "neoscroll.nvim": { "branch": "master", "commit": "21d52973bde32db998fc8b6590f87eb3c3c6d8e4" }, 25 | "nui.nvim": { "branch": "main", "commit": "3dc46d725f7b94bee5117c0a699b57b1902b5d65" }, 26 | "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, 27 | "nvim-dap": { "branch": "master", "commit": "c43c2473ecb482a9d91f32c1d4c0098fffad3c7d" }, 28 | "nvim-dap-go": { "branch": "main", "commit": "64f73400761e2d19459e664a52ea478f3a4420e7" }, 29 | "nvim-dap-ui": { "branch": "master", "commit": "9720eb5fa2f41988e8770f973cd11b76dd568a5d" }, 30 | "nvim-highlight-colors": { "branch": "main", "commit": "a9f191d5ba27a5943b8992bf618858fa7374758f" }, 31 | "nvim-lspconfig": { "branch": "master", "commit": "4bdd3800b4148f670c6cf55ef65f490148eeb550" }, 32 | "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, 33 | "nvim-treesitter": { "branch": "master", "commit": "f87882858438834d2fbb6379aa2be37de901751b" }, 34 | "nvim-treesitter-textobjects": { "branch": "master", "commit": "d2a4ffc22d9d38d44edb73da007b3cf43451e9b4" }, 35 | "nvim-web-devicons": { "branch": "master", "commit": "a851380fbea4c1312d11f13d5cdc86a7a19808dd" }, 36 | "plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" }, 37 | "refactoring.nvim": { "branch": "master", "commit": "d2786877c91aa409c824f27b4ce8a9f560dda60a" }, 38 | "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, 39 | "telescope.nvim": { "branch": "0.1.x", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" }, 40 | "tmux.nvim": { "branch": "main", "commit": "63e9c5e054099dd30af306bd8ceaa2f1086e1b07" }, 41 | "toggleterm.nvim": { "branch": "main", "commit": "193786e0371e3286d3bc9aa0079da1cd41beaa62" }, 42 | "vim-fugitive": { "branch": "master", "commit": "41beedabc7e948c787ea5696e04c3544c3674e23" }, 43 | "vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" }, 44 | "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, 45 | "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, 46 | "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } 47 | } -------------------------------------------------------------------------------- /lua/lsp/lsp-setup.lua: -------------------------------------------------------------------------------- 1 | -- [[ Configure LSP ]] 2 | local navic = require("nvim-navic") 3 | -- This function gets run when an LSP connects to a particular buffer. 4 | local on_attach = function(client, bufnr) 5 | -- NOTE: Remember that lua is a real programming language, and as such it is possible 6 | -- to define small helper and utility functions so you don't have to repeat yourself 7 | -- many times. 8 | -- 9 | -- In this case, we create a function that lets us more easily define mappings specific 10 | -- for LSP related items. It sets the mode, buffer and description for us each time. 11 | local nmap = function(keys, func, desc) 12 | if desc then 13 | desc = 'LSP: ' .. desc 14 | end 15 | 16 | vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) 17 | end 18 | 19 | if client.server_capabilities.documentSymbolProvider then 20 | navic.attach(client, bufnr) 21 | end 22 | nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') 23 | nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') 24 | 25 | nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') 26 | nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') 27 | nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') 28 | nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') 29 | nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') 30 | nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') 31 | 32 | -- See `:help K` for why this keymap 33 | nmap('K', vim.lsp.buf.hover, 'Hover Documentation') 34 | nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') 35 | 36 | -- Lesser used LSP functionality 37 | nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') 38 | nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') 39 | nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') 40 | nmap('wl', function() 41 | print(vim.inspect(vim.lsp.buf.list_workspace_folders())) 42 | end, '[W]orkspace [L]ist Folders') 43 | 44 | -- Create a command `:Format` local to the LSP buffer 45 | vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) 46 | vim.lsp.buf.format() 47 | end, { desc = 'Format current buffer with LSP' }) 48 | end 49 | 50 | -- document existing key chains 51 | require('which-key').register { 52 | ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, 53 | ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, 54 | ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, 55 | ['h'] = { name = 'More git', _ = 'which_key_ignore' }, 56 | ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, 57 | ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, 58 | ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, 59 | } 60 | 61 | -- mason-lspconfig requires that these setup functions are called in this order 62 | -- before setting up the servers. 63 | require('mason').setup() 64 | require('mason-lspconfig').setup() 65 | 66 | -- Enable the following language servers 67 | -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. 68 | -- 69 | -- Add any additional override configuration in the following tables. They will be passed to 70 | -- the `settings` field of the server config. You must look up that documentation yourself. 71 | -- 72 | -- If you want to override the default filetypes that your language server will attach to you can 73 | -- define the property 'filetypes' to the map in question. 74 | local servers = { 75 | -- clangd = {}, 76 | -- gopls = {}, 77 | pyright = {}, 78 | rust_analyzer = {}, 79 | elixirls = {}, 80 | -- tsserver = {}, 81 | -- html = { filetypes = { 'html', 'twig', 'hbs'} }, 82 | 83 | lua_ls = { 84 | Lua = { 85 | workspace = { checkThirdParty = false }, 86 | telemetry = { enable = false }, 87 | }, 88 | }, 89 | } 90 | 91 | -- Setup neovim lua configuration 92 | require('neodev').setup() 93 | 94 | -- nvim-cmp supports additional completion capabilities, so broadcast that to servers 95 | local capabilities = vim.lsp.protocol.make_client_capabilities() 96 | capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) 97 | 98 | -- Ensure the servers above are installed 99 | local mason_lspconfig = require 'mason-lspconfig' 100 | 101 | mason_lspconfig.setup { 102 | ensure_installed = vim.tbl_keys(servers), 103 | } 104 | 105 | mason_lspconfig.setup_handlers { 106 | function(server_name) 107 | require('lspconfig')[server_name].setup { 108 | capabilities = capabilities, 109 | on_attach = on_attach, 110 | settings = servers[server_name], 111 | filetypes = (servers[server_name] or {}).filetypes, 112 | } 113 | end, 114 | } 115 | 116 | -- vim: ts=2 sts=2 sw=2 et 117 | --------------------------------------------------------------------------------