From ecefe3b413dd0353851204f1f76407b93cf57bde Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 17 Jan 2026 21:17:29 +0000 Subject: [PATCH] nvim: add config files --- nvim/after/ftplugin/cpp.vim | 4 + nvim/after/ftplugin/less.vim | 3 + nvim/after/ftplugin/lua.vim | 2 + nvim/after/ftplugin/pug.vim | 3 + nvim/init.lua | 6 + nvim/lazy-lock.json | 31 ++++ nvim/lsp/clangd.lua | 5 + nvim/lua/config/autocmd.lua | 5 + nvim/lua/config/globals.lua | 7 + nvim/lua/config/keybinds.lua | 31 ++++ nvim/lua/config/lazy.lua | 35 +++++ nvim/lua/config/lsp.lua | 43 ++++++ nvim/lua/config/misc.lua | 1 + nvim/lua/plugins/asciidoctor.lua | 3 + nvim/lua/plugins/auto-dark-mode.lua | 19 +++ nvim/lua/plugins/catppuccin.lua | 98 ++++++++++++ nvim/lua/plugins/dashboard-nvim.lua | 75 +++++++++ nvim/lua/plugins/dev.lua | 9 ++ nvim/lua/plugins/hop.lua | 12 ++ nvim/lua/plugins/llvm.lua | 3 + nvim/lua/plugins/lsp-zero.lua.bak | 229 ++++++++++++++++++++++++++++ nvim/lua/plugins/lualine.lua | 9 ++ nvim/lua/plugins/neorg.lua | 55 +++++++ nvim/lua/plugins/nvim-cmp.lua | 85 +++++++++++ nvim/lua/plugins/project.nvim.lua | 20 +++ nvim/lua/plugins/pug.lua | 4 + nvim/lua/plugins/telescope.lua | 79 ++++++++++ nvim/lua/plugins/tmuxline.lua | 3 + nvim/lua/plugins/toggleterm.lua | 30 ++++ nvim/lua/plugins/treesitter.lua | 14 ++ 30 files changed, 923 insertions(+) create mode 100644 nvim/after/ftplugin/cpp.vim create mode 100644 nvim/after/ftplugin/less.vim create mode 100644 nvim/after/ftplugin/lua.vim create mode 100644 nvim/after/ftplugin/pug.vim create mode 100644 nvim/init.lua create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lsp/clangd.lua create mode 100644 nvim/lua/config/autocmd.lua create mode 100644 nvim/lua/config/globals.lua create mode 100644 nvim/lua/config/keybinds.lua create mode 100644 nvim/lua/config/lazy.lua create mode 100644 nvim/lua/config/lsp.lua create mode 100644 nvim/lua/config/misc.lua create mode 100644 nvim/lua/plugins/asciidoctor.lua create mode 100644 nvim/lua/plugins/auto-dark-mode.lua create mode 100644 nvim/lua/plugins/catppuccin.lua create mode 100644 nvim/lua/plugins/dashboard-nvim.lua create mode 100644 nvim/lua/plugins/dev.lua create mode 100644 nvim/lua/plugins/hop.lua create mode 100644 nvim/lua/plugins/llvm.lua create mode 100644 nvim/lua/plugins/lsp-zero.lua.bak create mode 100644 nvim/lua/plugins/lualine.lua create mode 100644 nvim/lua/plugins/neorg.lua create mode 100644 nvim/lua/plugins/nvim-cmp.lua create mode 100644 nvim/lua/plugins/project.nvim.lua create mode 100644 nvim/lua/plugins/pug.lua create mode 100644 nvim/lua/plugins/telescope.lua create mode 100644 nvim/lua/plugins/tmuxline.lua create mode 100644 nvim/lua/plugins/toggleterm.lua create mode 100644 nvim/lua/plugins/treesitter.lua diff --git a/nvim/after/ftplugin/cpp.vim b/nvim/after/ftplugin/cpp.vim new file mode 100644 index 0000000..740e3be --- /dev/null +++ b/nvim/after/ftplugin/cpp.vim @@ -0,0 +1,4 @@ +setlocal shiftwidth=8 +setlocal tabstop=8 + +set cinoptions+=g0 diff --git a/nvim/after/ftplugin/less.vim b/nvim/after/ftplugin/less.vim new file mode 100644 index 0000000..e882df7 --- /dev/null +++ b/nvim/after/ftplugin/less.vim @@ -0,0 +1,3 @@ +setlocal expandtab +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/nvim/after/ftplugin/lua.vim b/nvim/after/ftplugin/lua.vim new file mode 100644 index 0000000..289b7cd --- /dev/null +++ b/nvim/after/ftplugin/lua.vim @@ -0,0 +1,2 @@ +setlocal shiftwidth=4 +setlocal tabstop=4 diff --git a/nvim/after/ftplugin/pug.vim b/nvim/after/ftplugin/pug.vim new file mode 100644 index 0000000..e882df7 --- /dev/null +++ b/nvim/after/ftplugin/pug.vim @@ -0,0 +1,3 @@ +setlocal expandtab +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..2696764 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,6 @@ +require("config.globals") +require("config.lazy") +require("config.autocmd") +require("config.misc") +require("config.lsp") +require("config.keybinds") diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..c25f16a --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,31 @@ +{ + "LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" }, + "auto-dark-mode.nvim": { "branch": "master", "commit": "e300259ec777a40b4b9e3c8e6ade203e78d15881" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "fd3e882e56956675c620898bf1ffcf4fcbe7ec84" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, + "dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" }, + "hop.nvim": { "branch": "master", "commit": "1a1eceafe54b5081eae4cb91c723abd1d450f34b" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "llvm.vim": { "branch": "master", "commit": "0c5a25b1d79c939955e3fa52b086d0318b891b2b" }, + "lspkind.nvim": { "branch": "master", "commit": "3ddd1b4edefa425fda5a9f95a4f25578727c0bb3" }, + "lua-utils.nvim": { "branch": "main", "commit": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "neorg": { "branch": "main", "commit": "408fc04013a95da8f217cb0958a06b6a77c01743" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" }, + "nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" }, + "pathlib.nvim": { "branch": "main", "commit": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, + "telescope-ag": { "branch": "main", "commit": "7d25064da3c7689461bcfa89ad1f08548415193d" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "tmuxline.vim": { "branch": "master", "commit": "4119c553923212cc67f4e135e6f946dc3ec0a4d6" }, + "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, + "vim-asciidoctor": { "branch": "master", "commit": "d45364d662489e0ffcad0e2bc6f41c859ba58799" }, + "vim-pug": { "branch": "master", "commit": "ea39cd942cf3194230cf72bfb838901a5344d3b3" }, + "vim-vsnip": { "branch": "master", "commit": "9bcfabea653abdcdac584283b5097c3f8760abaa" } +} diff --git a/nvim/lsp/clangd.lua b/nvim/lsp/clangd.lua new file mode 100644 index 0000000..290bc27 --- /dev/null +++ b/nvim/lsp/clangd.lua @@ -0,0 +1,5 @@ +return { + cmd = { 'clangd' }, + filetypes = { 'c', 'h', 'cpp', 'cc', 'hpp', 'm' }, + root_markers = { 'build/' }, +} diff --git a/nvim/lua/config/autocmd.lua b/nvim/lua/config/autocmd.lua new file mode 100644 index 0000000..48caa8a --- /dev/null +++ b/nvim/lua/config/autocmd.lua @@ -0,0 +1,5 @@ +vim.api.nvim_create_autocmd({ "BufWritePre" }, { + pattern = { "*" }, + command = "%s/\\s\\+$//e" +}) + diff --git a/nvim/lua/config/globals.lua b/nvim/lua/config/globals.lua new file mode 100644 index 0000000..092e33f --- /dev/null +++ b/nvim/lua/config/globals.lua @@ -0,0 +1,7 @@ +vim.opt.updatetime = 750 +vim.opt.colorcolumn = "80" +vim.opt.conceallevel = 2 +vim.opt.nuw = 6 +vim.opt.number = true +vim.opt.cursorline = true +vim.opt.cursorlineopt = "number" diff --git a/nvim/lua/config/keybinds.lua b/nvim/lua/config/keybinds.lua new file mode 100644 index 0000000..d4a1467 --- /dev/null +++ b/nvim/lua/config/keybinds.lua @@ -0,0 +1,31 @@ +-- Set leader key to Space +vim.g.mapleader = ' ' + +-- When lsp-signature (or any other vsnip snippet) is active, press TAB to jump +-- to the next placehol +--imap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' +--smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' + +--imap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' +--smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' + +-- Map semicolon to colon, so you don't have to press shift to enter commands +vim.keymap.set('n', ';', ':') + +-- Map shift-space to underscore +--vim.keymap.set('i', '', '_') + +vim.keymap.set('n', 'H', function() vim.cmd('wincmd h') end, { remap = true }) +vim.keymap.set('n', 'J', function() vim.cmd('wincmd j') end, { remap = true }) +vim.keymap.set('n', 'K', function() vim.cmd('wincmd k') end, { remap = true }) +vim.keymap.set('n', 'L', function() vim.cmd('wincmd l') end, { remap = true }) + +vim.keymap.set('n', '', function() vim.cmd('vertical resize -1') end, {}) +vim.keymap.set('n', '', function() vim.cmd('horizontal resize -1') end, {}) +vim.keymap.set('n', '', function() vim.cmd('horizontal resize +1') end, {}) +vim.keymap.set('n', '', function() vim.cmd('vertical resize +1') end, {}) + +--nmap :ToggleTerm +--imap :ToggleTerm + +--nmap t :ToggleTerm diff --git a/nvim/lua/config/lazy.lua b/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/nvim/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/nvim/lua/config/lsp.lua b/nvim/lua/config/lsp.lua new file mode 100644 index 0000000..9f42bb2 --- /dev/null +++ b/nvim/lua/config/lsp.lua @@ -0,0 +1,43 @@ +function show_diagnostic() + for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do + if vim.api.nvim_win_get_config(winid).zindex then + return + end + end + -- THIS IS FOR BUILTIN LSP + vim.diagnostic.open_float(0, { + scope = "cursor", + focusable = false, + close_events = { + "CursorMoved", + "CursorMovedI", + "BufHidden", + "InsertCharPre", + "WinLeave", + }, + }) +end + +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("lsp", { clear = true }), + callback = function (args) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = args.buf, + callback = function () + vim.lsp.buf.format { async = false, id = args.data.client_id } + end, + }) + + vim.api.nvim_create_autocmd("CursorHold", { + pattern = '*', + callback = show_diagnostic + }) + end +}) + +vim.lsp.enable('clangd') + +local capabilities = require('cmp_nvim_lsp').default_capabilities() +vim.lsp.config('clangd', { + capabilities = capabilities +}) diff --git a/nvim/lua/config/misc.lua b/nvim/lua/config/misc.lua new file mode 100644 index 0000000..ee61dc1 --- /dev/null +++ b/nvim/lua/config/misc.lua @@ -0,0 +1 @@ +vim.cmd('syntax sync minlines=20') diff --git a/nvim/lua/plugins/asciidoctor.lua b/nvim/lua/plugins/asciidoctor.lua new file mode 100644 index 0000000..4c40081 --- /dev/null +++ b/nvim/lua/plugins/asciidoctor.lua @@ -0,0 +1,3 @@ +return { + 'habamax/vim-asciidoctor', +} diff --git a/nvim/lua/plugins/auto-dark-mode.lua b/nvim/lua/plugins/auto-dark-mode.lua new file mode 100644 index 0000000..5a670b4 --- /dev/null +++ b/nvim/lua/plugins/auto-dark-mode.lua @@ -0,0 +1,19 @@ +ssh_client = os.getenv("SSH_CLIENT") + +if ssh_client == nil or string.len(ssh_client) == 0 then + return { + "f-person/auto-dark-mode.nvim", + priority = 1100, + opts = { + update_interval = 1000, + set_dark_mode = function() + vim.cmd("colorscheme catppuccin-mocha") + end, + set_light_mode = function() + vim.cmd("colorscheme catppuccin-latte") + end, + }, + } +else + return {} +end diff --git a/nvim/lua/plugins/catppuccin.lua b/nvim/lua/plugins/catppuccin.lua new file mode 100644 index 0000000..87f6533 --- /dev/null +++ b/nvim/lua/plugins/catppuccin.lua @@ -0,0 +1,98 @@ +return { + "catppuccin/nvim", + lazy = false, + priority = 1000, + config = function() + 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 = true, -- shows the '~' characters after the end of buffers + term_colors = true, -- sets terminal colors (e.g. `g:terminal_color_0`) + dim_inactive = { + enabled = true, -- dims the background color of inactive window + shade = "dark", + percentage = 0.15, -- percentage of the shade to apply to the inactive window + }, + no_italic = true, -- 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 = {}, + loops = {}, + functions = { "italic" }, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = { "bold" }, + operators = {}, + }, + color_overrides = {}, + highlight_overrides = { + all = function(colors) + return { + DashboardHeader = { fg = colors.yellow }, + DashboardHotkeyFiles = { fg = colors.flamingo }, + DashboardHotkeyProjects = { fg = colors.lavender }, + DashboardHotkeyNotes = { fg = colors.pink }, + DashboardHotkeyDotfiles = { fg = colors.sapphire }, + DashboardHotkeyNotifications = { fg = colors.peach }, + DashboardHotkeyQuit = { fg = colors.red }, + + StorageClass = { fg = colors.lavender }, + Structure = { fg = colors.lavender } , + --Identifier = { fg = colors.yellow } , + ["@lsp.type.class.c"] = { fg = colors.yellow }, + ["@lsp.type.class.cpp"] = { fg = colors.yellow }, + ["@lsp.type.enum.c"] = { fg = colors.yellow }, + ["@lsp.type.enum.cpp"] = { fg = colors.yellow }, + ["@lsp.type.macro.c"] = { fg = colors.peach }, + ["@lsp.type.macro.cpp"] = { fg = colors.peach }, + ["@function.builtin"] = { fg = colors.blue }, + ["@property"] = { fg = colors.rosewater }, + PreProc = { fg = colors.mauve }, + } + end, + mocha = function(colors) + return { + String = { fg = colors.green, bg = '#292a36' }, + Special = { fg = colors.red, bg = '#292a36' }, + CursorLineNr = { fg = colors.lavender, bg = '#2a2b3c' } + } + end, + latte = function(colors) + return { + --String = { fg = colors.green, bg = '#d9f3da' }, + --Special = { fg = colors.red, bg = '#d9f3da' }, + CursorLineNr = { fg = colors.lavender, bg = '#dce4f7' } + } + end + }, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + notify = true, + hop = true, + noice = true, + telescope = { + enabled = true, + }, + mini = { + enabled = true, + indentscope_color = "", + }, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, + } + vim.cmd([[colorscheme catppuccin]]) + end, +} diff --git a/nvim/lua/plugins/dashboard-nvim.lua b/nvim/lua/plugins/dashboard-nvim.lua new file mode 100644 index 0000000..b362573 --- /dev/null +++ b/nvim/lua/plugins/dashboard-nvim.lua @@ -0,0 +1,75 @@ + +return { + 'nvimdev/dashboard-nvim', + -- event = 'VimEnter', + config = function() + require('dashboard').setup { + theme = 'hyper', + config = { + week_header = { + enable = false, + }, + packages = { + enable = false, + }, + --header = { + -- " __ _ ", + -- " /\\ \\ \\__ _(_)_ __ ___ ", + -- " / \\/ /\\ \\ / / | '_ ` _ \\ ", + -- "/ /\\ / \\ V /| | | | | | |", + -- "\\_\\ \\/ \\_/ |_|_| |_| |_|", + -- "==================================", + -- "on " .. vim.fn.hostname(), + -- "" + --}, + header = { + " ___ __ __ ", + " / | / /____/ /_ ___ ____ ___ __ __", + " / /| | / / ___/ __ \\/ _ \\/ __ `__ \\/ / / /", + " / ___ |/ / /__/ / / / __/ / / / / / /_/ / ", + "/_/ |_/_/\\___/_/ /_/\\___/_/ /_/ /_/\\__, / ", + " Nvim /____/ ", + "............................................", + "on " .. vim.fn.hostname(), + "" + }, + shortcut = { + { + desc = ' Files', + action = 'Telescope find_files', + group = 'DashboardHotkeyFiles', + key = 'f', + }, + { + desc = ' Projects', + group = 'DashboardHotkeyProjects', + action = 'Telescope projects', + key = 'p', + }, + { + desc = ' Notes', + group = 'DashboardHotkeyNotes', + action = 'SearchNotes', + key = 'n', + }, + { + desc = ' dotfiles', + group = 'DashboardHotkeyDotfiles', + action = 'SearchDotfiles', + key = 'd', + }, + { + desc = ' Quit', + group = 'DashboardHotkeyQuit', + action = 'q', + key = 'q', + }, + } + }, + } + end, + dependencies = { + 'nvim-tree/nvim-web-devicons', + 'nvim-telescope/telescope.nvim', + } +} diff --git a/nvim/lua/plugins/dev.lua b/nvim/lua/plugins/dev.lua new file mode 100644 index 0000000..11d91e3 --- /dev/null +++ b/nvim/lua/plugins/dev.lua @@ -0,0 +1,9 @@ +return { + { + dir = '~/projects/ivy/ivy.vim' + }, + { + dir = '~/projects/mie/mie.vim' + } +} + diff --git a/nvim/lua/plugins/hop.lua b/nvim/lua/plugins/hop.lua new file mode 100644 index 0000000..d6c8b89 --- /dev/null +++ b/nvim/lua/plugins/hop.lua @@ -0,0 +1,12 @@ +return { + 'phaazon/hop.nvim', + config = function() + local hop = require('hop') + hop.setup { + keys = 'asdfweq' + } + + vim.keymap.set('n', 'W', hop.hint_words, {}) + vim.keymap.set('n', 'L', hop.hint_lines, {}) + end +} diff --git a/nvim/lua/plugins/llvm.lua b/nvim/lua/plugins/llvm.lua new file mode 100644 index 0000000..51c59e6 --- /dev/null +++ b/nvim/lua/plugins/llvm.lua @@ -0,0 +1,3 @@ +return { + 'b1narykid/llvm.vim' +} diff --git a/nvim/lua/plugins/lsp-zero.lua.bak b/nvim/lua/plugins/lsp-zero.lua.bak new file mode 100644 index 0000000..6560c84 --- /dev/null +++ b/nvim/lua/plugins/lsp-zero.lua.bak @@ -0,0 +1,229 @@ +local cmp_kinds = { + Text = ' ', + Method = ' ', + Function = ' ', + Constructor = ' ', + Field = ' ', + Variable = ' ', + Class = ' ', + Interface = ' ', + Module = ' ', + Property = ' ', + Unit = ' ', + Value = ' ', + Enum = ' ', + Keyword = ' ', + Snippet = ' ', + Color = ' ', + File = ' ', + Reference = ' ', + Folder = ' ', + EnumMember = ' ', + Constant = ' ', + Struct = ' ', + Event = ' ', + Operator = ' ', + TypeParameter = ' ', +} + +local border = { + { "╭", "CmpBorder" }, + { "─", "CmpBorder" }, + { "╮", "CmpBorder" }, + { "│", "CmpBorder" }, + { "╯", "CmpBorder" }, + { "─", "CmpBorder" }, + { "╰", "CmpBorder" }, + { "│", "CmpBorder" }, +} + +function show_diagnostic() + for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do + if vim.api.nvim_win_get_config(winid).zindex then + return + end + end + -- THIS IS FOR BUILTIN LSP + vim.diagnostic.open_float(0, { + scope = "cursor", + focusable = false, + close_events = { + "CursorMoved", + "CursorMovedI", + "BufHidden", + "InsertCharPre", + "WinLeave", + }, + }) +end + +local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +local feedkey = function(key, mode) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) +end + +return { + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + lazy = true, + config = false, + init = function() + vim.g.lsp_zero_extend_cmp = 0 + vim.g.lsp_zero_extend_lspconfig = 0 + end, + }, + { + 'williamboman/mason.nvim', + lazy = false, + config = true + }, + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + 'L3MON4D3/LuaSnip', + 'hrsh7th/cmp-vsnip', + 'hrsh7th/vim-vsnip', + 'onsails/lspkind.nvim', + 'hrsh7th/cmp-nvim-lsp-signature-help' + }, + config = function() + local lsp_zero = require('lsp-zero') + lsp_zero.extend_cmp() + + local cmp = require('cmp') + local cmp_action = lsp_zero.cmp_action() + + cmp.setup { + --formatting = lsp_zero.cmp_format({ details = true }), + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + format = function(entry, vim_item) + local lspkind = require('lspkind') + local kind = lspkind.cmp_format({ + mode = "symbol_text", + maxwidth = 50 + })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. (strings[1] or "") .. " " + kind.menu = " (" .. (strings[2] or "") .. ")" + + return kind + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + { name = 'neorg' }, + { name = 'nvim_lsp_signature_help' } + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp_action.luasnip_jump_forward(), + [''] = cmp_action.luasnip_jump_backward(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + --elseif has_words_before() then + -- cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-jump-prev)", "") + else + fallback() + end + end, { "i", "s" }), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = false }), + }), + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end + }, + sorting = { + comparators = { + cmp.config.compare.length, + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.order, + }, + }, + } + end + }, + { + 'neovim/nvim-lspconfig', + cmp = { 'LspInfo', 'LspInstall', 'LspStart' }, + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'williamboman/mason-lspconfig.nvim' + }, + config = function() + local lsp_zero = require('lsp-zero') + lsp_zero.extend_lspconfig() + + lsp_zero.on_attach(function(client, bufnr) + lsp_zero.default_keymaps({ bufnr = bufnr }) + end) + + local util = require('lspconfig.util') + local capabilities = vim.tbl_deep_extend( + 'force', + vim.lsp.protocol.make_client_capabilities(), + require('cmp_nvim_lsp').default_capabilities() + ) + capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = false + + vim.lsp.enable('clangd') + vim.lsp.config('clangd', { + root_dir = util.root_pattern('build'), + capabilities = capabilities, + init_options = { + compilationDatabasePath = './build', + highlight = { + lsRanges = true + } + } + }) + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("lsp", { clear = true }), + callback = function (args) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = args.buf, + callback = function () + vim.lsp.buf.format { async = false, id = args.data.client_id } + end, + }) + + vim.api.nvim_create_autocmd("CursorHold", { + pattern = '*', + callback = show_diagnostic + }) + end + }) + end + } +} + diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..719a57a --- /dev/null +++ b/nvim/lua/plugins/lualine.lua @@ -0,0 +1,9 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + config = function() + require('lualine').setup() + end +} diff --git a/nvim/lua/plugins/neorg.lua b/nvim/lua/plugins/neorg.lua new file mode 100644 index 0000000..90b847e --- /dev/null +++ b/nvim/lua/plugins/neorg.lua @@ -0,0 +1,55 @@ +return { + "nvim-neorg/neorg", + lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default + version = "*", -- Pin Neorg to the latest stable release + config = function() + local neorg = require("neorg") + + neorg.setup { + load = { + ["core.defaults"] = {}, + ["core.esupports.indent"] = { + config = { + tweaks = { + heading2 = 1, + heading3 = 2, + heading4 = 3, + heading5 = 4, + heading6 = 5, + + unordered_list2 = 1, + unordered_list3 = 2, + unordered_list4 = 3, + unordered_list5 = 4, + unordered_list6 = 5, + + ordered_list2 = 1, + ordered_list3 = 2, + ordered_list4 = 3, + ordered_list5 = 4, + ordered_list6 = 5, + + paragraph_segment = 1, + } + } + }, + ["core.concealer"] = { + config = { + icons = { + code_block = { + conceal = true, + padding = { + left = 2, + right = 2, + }, + width = 80, + }, + }, + }, + }, + } + } + + --vim.keymap.set('n', 'N', function() vim.cmd(':e ~/notes/index.norg') end, {}) + end, +} diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..900bf30 --- /dev/null +++ b/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,85 @@ +return { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + 'L3MON4D3/LuaSnip', + 'hrsh7th/cmp-vsnip', + 'hrsh7th/vim-vsnip', + 'hrsh7th/cmp-nvim-lsp', + 'onsails/lspkind.nvim', + 'hrsh7th/cmp-nvim-lsp-signature-help' + }, + config = function() + local cmp = require('cmp') + + cmp.setup { + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + format = function(entry, vim_item) + local lspkind = require('lspkind') + local kind = lspkind.cmp_format({ + mode = "symbol_text", + maxwidth = 50 + })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. (strings[1] or "") .. " " + kind.menu = " (" .. (strings[2] or "") .. ")" + + return kind + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + { name = 'neorg' }, + { name = 'nvim_lsp_signature_help' } + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + --[''] = cmp_action.luasnip_jump_forward(), + --[''] = cmp_action.luasnip_jump_backward(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + --elseif has_words_before() then + -- cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-jump-prev)", "") + else + fallback() + end + end, { "i", "s" }), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = false }), + }), + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end + }, + sorting = { + comparators = { + cmp.config.compare.length, + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.order, + }, + }, + } + end + } diff --git a/nvim/lua/plugins/project.nvim.lua b/nvim/lua/plugins/project.nvim.lua new file mode 100644 index 0000000..004a15d --- /dev/null +++ b/nvim/lua/plugins/project.nvim.lua @@ -0,0 +1,20 @@ +return { + 'ahmedkhalf/project.nvim', + config = function() + local project_nvim = require('project_nvim') + project_nvim.setup { + manual_mode = false, + detection_methods = { 'pattern' }, + theme = 'ivy', + patterns = { + '>projects', + '.git', + } + } + + local telescope = require('telescope') + telescope.load_extension('projects') + vim.keymap.set('n', 'fp', telescope.extensions.projects.projects, { desc = 'Find Projects' }) + end +} + diff --git a/nvim/lua/plugins/pug.lua b/nvim/lua/plugins/pug.lua new file mode 100644 index 0000000..103dcf3 --- /dev/null +++ b/nvim/lua/plugins/pug.lua @@ -0,0 +1,4 @@ + +return { + 'digitaltoad/vim-pug', +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..085ace6 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,79 @@ +local init = function() + local telescope = require('telescope') + local themes = require('telescope.themes') + local actions = require('telescope.actions') + + telescope.setup { + defaults = themes.get_ivy { + file_ignore_pattern = { 'build', '.cache', '.ccls*' }, + sorting_strategy = 'ascending', + preview = false, + layout_config = { + horizontal = { + prompt_position = 'top', + }, + }, + }, + pickers = { + find_files = { + find_command = { 'rg', '--ignore', '-L', '--files' }, + theme = 'ivy', + mappings = { + i = { + [''] = actions.close, + [''] = { '', type = 'command' } + } + } + }, + } + } + + local builtin = require('telescope.builtin') + + vim.api.nvim_create_user_command( + 'SearchDotfiles', + function(opts) + builtin.find_files({ cwd = '~/.config/nvim' }) + end, + {}) + + vim.api.nvim_create_user_command( + 'SearchNotes', + function(opts) + builtin.find_files({ cwd = '~/notes' }) + end, + {}) + + vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fd', function() vim.cmd('SearchDotfiles') end, {}) + vim.keymap.set('n', 'fn', function() vim.cmd('SearchNotes') end, {}) + vim.keymap.set('n', 'fb', function() vim.cmd('Telescope buffers') end, {}) + vim.keymap.set('n', 'fs', function() vim.cmd('Telescope lsp_dynamic_workspace_symbols') end, {}) +end + +return { + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + priority = 1000, + dependencies = { + 'nvim-lua/plenary.nvim' + }, + config = init + }, + { + 'kelly-lin/telescope-ag', + dependencies = { + 'nvim-telescope/telescope.nvim' + }, + config = function() + local telescope_ag = require('telescope-ag') + telescope_ag.setup({ + cmd = telescope_ag.cmds.ag, + }) + + local telescope = require('telescope') + telescope.load_extension("ag") + end + } +} diff --git a/nvim/lua/plugins/tmuxline.lua b/nvim/lua/plugins/tmuxline.lua new file mode 100644 index 0000000..ae79684 --- /dev/null +++ b/nvim/lua/plugins/tmuxline.lua @@ -0,0 +1,3 @@ +return { + 'edkolev/tmuxline.vim' +} diff --git a/nvim/lua/plugins/toggleterm.lua b/nvim/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..33dc36a --- /dev/null +++ b/nvim/lua/plugins/toggleterm.lua @@ -0,0 +1,30 @@ +function _G.set_terminal_keymaps() + local opts = {buffer = 0} + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', '', [[wincmd h]], opts) + vim.keymap.set('t', '', [[wincmd j]], opts) + vim.keymap.set('t', '', [[wincmd k]], opts) + vim.keymap.set('t', '', [[wincmd l]], opts) + vim.keymap.set('t', '', [[]], opts) +end + +return { + 'akinsho/toggleterm.nvim', + config = function() + require('toggleterm').setup{ + direction = 'float', + float_opts = { + border = 'single', + width = 80, + height = 25, + row = 2, + col = 2, + winblend = 3, + title_pos = 'right' + }, + } + + vim.keymap.set('n', 't', function() vim.cmd('ToggleTerm') end, {}) + vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + end +} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..c77d735 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + local configs = require('nvim-treesitter.configs') + + configs.setup { + ensure_installed = { 'c', 'cpp', 'lua', 'vimdoc', 'luadoc', 'vim', 'markdown' }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = false } + } + end +}