From 22b7110ebd91f3358fe1f3a414e53f46477045cf Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sat, 4 Feb 2023 04:17:42 +0000 Subject: [PATCH] feat(nvim): steal @backwardspy config --- dot_config/nvim/init.lua | 61 ++++++ dot_config/nvim/lazy-lock.json | 62 ++++++ dot_config/nvim/lua/binds.lua | 52 +++++ dot_config/nvim/lua/options.lua | 54 +++++ dot_config/nvim/lua/plugins/asciiblocks.lua | 3 + dot_config/nvim/lua/plugins/asciitree.lua | 3 + dot_config/nvim/lua/plugins/autopairs.lua | 16 ++ dot_config/nvim/lua/plugins/catppuccin.lua | 58 ++++++ dot_config/nvim/lua/plugins/ccc.lua | 3 + dot_config/nvim/lua/plugins/cmp.lua | 110 ++++++++++ dot_config/nvim/lua/plugins/cmp.lua~ | 95 +++++++++ dot_config/nvim/lua/plugins/comment.lua | 3 + dot_config/nvim/lua/plugins/coverage.lua | 7 + dot_config/nvim/lua/plugins/dap.lua | 82 ++++++++ dot_config/nvim/lua/plugins/delaytrain.lua | 9 + dot_config/nvim/lua/plugins/feline.lua | 14 ++ dot_config/nvim/lua/plugins/init.lua | 8 + dot_config/nvim/lua/plugins/lsp.lua | 189 ++++++++++++++++++ dot_config/nvim/lua/plugins/mason.lua | 6 + dot_config/nvim/lua/plugins/mini.lua | 18 ++ dot_config/nvim/lua/plugins/netrw.lua | 3 + dot_config/nvim/lua/plugins/noice.lua | 35 ++++ dot_config/nvim/lua/plugins/overseer.lua | 11 + dot_config/nvim/lua/plugins/quickscope.lua | 8 + dot_config/nvim/lua/plugins/searchreplace.lua | 8 + dot_config/nvim/lua/plugins/surround.lua | 3 + dot_config/nvim/lua/plugins/telescope.lua | 28 +++ dot_config/nvim/lua/plugins/treesitter.lua | 40 ++++ dot_config/nvim/lua/plugins/which_key.lua | 31 +++ dot_config/nvim/lua/plugins/zenmode.lua | 20 ++ 30 files changed, 1040 insertions(+) create mode 100644 dot_config/nvim/init.lua create mode 100644 dot_config/nvim/lazy-lock.json create mode 100644 dot_config/nvim/lua/binds.lua create mode 100644 dot_config/nvim/lua/options.lua create mode 100644 dot_config/nvim/lua/plugins/asciiblocks.lua create mode 100644 dot_config/nvim/lua/plugins/asciitree.lua create mode 100644 dot_config/nvim/lua/plugins/autopairs.lua create mode 100644 dot_config/nvim/lua/plugins/catppuccin.lua create mode 100644 dot_config/nvim/lua/plugins/ccc.lua create mode 100644 dot_config/nvim/lua/plugins/cmp.lua create mode 100644 dot_config/nvim/lua/plugins/cmp.lua~ create mode 100644 dot_config/nvim/lua/plugins/comment.lua create mode 100644 dot_config/nvim/lua/plugins/coverage.lua create mode 100644 dot_config/nvim/lua/plugins/dap.lua create mode 100644 dot_config/nvim/lua/plugins/delaytrain.lua create mode 100644 dot_config/nvim/lua/plugins/feline.lua create mode 100644 dot_config/nvim/lua/plugins/init.lua create mode 100644 dot_config/nvim/lua/plugins/lsp.lua create mode 100644 dot_config/nvim/lua/plugins/mason.lua create mode 100644 dot_config/nvim/lua/plugins/mini.lua create mode 100644 dot_config/nvim/lua/plugins/netrw.lua create mode 100644 dot_config/nvim/lua/plugins/noice.lua create mode 100644 dot_config/nvim/lua/plugins/overseer.lua create mode 100644 dot_config/nvim/lua/plugins/quickscope.lua create mode 100644 dot_config/nvim/lua/plugins/searchreplace.lua create mode 100644 dot_config/nvim/lua/plugins/surround.lua create mode 100644 dot_config/nvim/lua/plugins/telescope.lua create mode 100644 dot_config/nvim/lua/plugins/treesitter.lua create mode 100644 dot_config/nvim/lua/plugins/which_key.lua create mode 100644 dot_config/nvim/lua/plugins/zenmode.lua diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua new file mode 100644 index 0000000..2c79281 --- /dev/null +++ b/dot_config/nvim/init.lua @@ -0,0 +1,61 @@ +-- set this early so plugins etc can all use it +vim.g.mapleader = " " +-- disable netrw at the very start of your init.lua (strongly advised) +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- bootstrap & set up lazy +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("plugins", { + install = { + colorscheme = { "catppuccin" }, + missing = true, + }, + change_detection = { + enabled = true, + notify = false, + }, + ui = { + border = "rounded", + icons = { + list = { "●" }, + }, + }, +}) + +-- load remaining config +require("options") +require("binds") + +-- highlight yank +vim.api.nvim_create_augroup("highlight_yank", {}) +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + group = "highlight_yank", + pattern = { "*" }, + callback = function() + vim.highlight.on_yank({ + higroup = "Visual", + timeout = 150, + }) + end, +}) + +-- Disable semantic highlights +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + client.server_capabilities.semanticTokensProvider = nil + end, +}) diff --git a/dot_config/nvim/lazy-lock.json b/dot_config/nvim/lazy-lock.json new file mode 100644 index 0000000..62d9551 --- /dev/null +++ b/dot_config/nvim/lazy-lock.json @@ -0,0 +1,62 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "eab2c83a0207369900e92783f56990808082eac2" }, + "LuaSnip": { "branch": "master", "commit": "d404ec306bfa4cdb0c3605dbb17e8a93a9597337" }, + "actually.nvim": { "branch": "main", "commit": "a735082694b1f06c4d9874f2a7288dba94acdb71" }, + "ascii-blocks.nvim": { "branch": "main", "commit": "a8a7d99fc52df30d7c4e7664818542fd44839d97" }, + "asciitree.nvim": { "branch": "main", "commit": "a979a0c6987e07eaa9f405d90c086105c0a2d99c" }, + "catppuccin": { "branch": "main", "commit": "8769e767f12f5bf0b7d1250ee067088e7054809a" }, + "ccc.nvim": { "branch": "main", "commit": "be0a8122fd77efb7b6a0d672bab10417e68fab8b" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "23c51b2a3c00f6abc4e922dbd7c3b9aca6992063" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "delaytrain.nvim": { "branch": "main", "commit": "eb8d2157e6a7de1b4f024f7ca5bccc4014d88b05" }, + "dressing.nvim": { "branch": "master", "commit": "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" }, + "feline.nvim": { "branch": "master", "commit": "d48b6f92c6ccdd6654c956f437be49ea160b5b0c" }, + "haskell-tools.nvim": { "branch": "master", "commit": "03dfa7fa3d08a34cdef09ca05a6da166a1ba22a2" }, + "lazy.nvim": { "branch": "main", "commit": "3d2dcb2d5ef99106c5ff412da88c6f59a9f8a693" }, + "lsp-format.nvim": { "branch": "master", "commit": "ca0df5c8544e51517209ea7b86ecc522c98d4f0a" }, + "lsp_signature.nvim": { "branch": "master", "commit": "6f6252f63b0baf0f2224c4caea33819a27f3f550" }, + "lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "53f3a8bdcb77d4a95b082fd57e12173f353c6c3e" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "13c6ab4a4f810cbbb1799a9cf4d4a27fd862d885" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "4feb21a598e690f947aa2c97129a469f772b5289" }, + "mason.nvim": { "branch": "main", "commit": "24846a00941ec020c8addc7f52040a1b2fc12174" }, + "mini.nvim": { "branch": "main", "commit": "4f97a8771a480bcacf1d1d0dbf82e47f682aba2c" }, + "neodev.nvim": { "branch": "main", "commit": "d9a8d651501cd2f287742472af4b3103d991cd68" }, + "null-ls.nvim": { "branch": "main", "commit": "8f5d730021497233c39d3adbf4b8043d4be163f8" }, + "nvim-autopairs": { "branch": "master", "commit": "5a3523ddb573804752de6c021c5cb82e267b79ca" }, + "nvim-bqf": { "branch": "main", "commit": "da1cd2557a16386829a213330e0fd46b61db7632" }, + "nvim-cmp": { "branch": "main", "commit": "cfafe0a1ca8933f7b7968a287d39904156f2c57d" }, + "nvim-coverage": { "branch": "main", "commit": "5c5ab0cc575c483bf3485b9481880b5ea4160ed4" }, + "nvim-dap": { "branch": "master", "commit": "0e376f00e7fac143e29e1017d2ac2cc3df13d185" }, + "nvim-dap-ui": { "branch": "master", "commit": "885e958ff9de30cfbc359259eccf28cc493ad46b" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "7f7f2af549e72a0b7bddc3b4f827beb027ea8ce3" }, + "nvim-lspconfig": { "branch": "master", "commit": "902d6aa31450d26e11bedcbef8af5b6fe2e1ffe8" }, + "nvim-navic": { "branch": "master", "commit": "11e08391eeed00effa85ca24ff9d1e0472cbcd6a" }, + "nvim-surround": { "branch": "main", "commit": "ad56e6234bf42fb7f7e4dccc7752e25abd5ec80e" }, + "nvim-tree.lua": { "branch": "master", "commit": "215b29bfad74518442621b9d0483a621483b066b" }, + "nvim-treesitter": { "branch": "master", "commit": "0e6d4b4172f30c4aa44a9adc9ea5719723a1fac3" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "249d90a84df63f3ffff65fcc06a45d58415672de" }, + "nvim-web-devicons": { "branch": "master", "commit": "2b96193abe4372e18e4f4533895a42a466d53c17" }, + "overseer.nvim": { "branch": "master", "commit": "42c0d69f505314d6994a84da4e3fcbaf308c1a86" }, + "plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" }, + "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "py_lsp.nvim": { "branch": "main", "commit": "6f160d0e1864b1a46c932c542a132a57abd7f1c1" }, + "quick-scope": { "branch": "master", "commit": "428e8698347f254d24b248af9f656194a80081e5" }, + "rust-tools.nvim": { "branch": "master", "commit": "b297167d9e01accc9b9afe872ce91e791df2dde0" }, + "search-replace.nvim": { "branch": "main", "commit": "b3485c9cd14319c5320bbdd74af0b3c67733490d" }, + "smart-open.nvim": { "branch": "main", "commit": "ebf87075af7d193c16800ce682a04eca393ac2a7" }, + "sqlite.lua": { "branch": "master", "commit": "93ff5824682ecc874200e338fd8ca9ccd08508f8" }, + "telescope-catppuccin.nvim": { "branch": "main", "commit": "92e028a34d917d5b4b891f8f4406c45c8cc6497e" }, + "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, + "telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" }, + "twilight.nvim": { "branch": "main", "commit": "9410252bed96887ca5a86bf16435a3a51a0e6ce5" }, + "vim-textobj-entire": { "branch": "master", "commit": "64a856c9dff3425ed8a863b9ec0a21dbaee6fb3a" }, + "vim-textobj-user": { "branch": "master", "commit": "41a675ddbeefd6a93664a4dc52f302fe3086a933" }, + "which-key.nvim": { "branch": "main", "commit": "684e96c5e8477f1ee9b3f2e9a12d802fd12c5531" }, + "zen-mode.nvim": { "branch": "main", "commit": "136dda65769cee45119f16e4bc3d3f13a7aecb28" } +} \ No newline at end of file diff --git a/dot_config/nvim/lua/binds.lua b/dot_config/nvim/lua/binds.lua new file mode 100644 index 0000000..d6016cb --- /dev/null +++ b/dot_config/nvim/lua/binds.lua @@ -0,0 +1,52 @@ +local wk = require("which-key") + +wk.register({ + ["0"] = { "0^", "" } +}) + +-- normal binds +wk.register({ + [""] = { "write", "Save" }, + [""] = { "zz", "Half page down" }, + [""] = { "zz", "Half page up" }, + n = { "nzzzv", "Next result (centered)" }, + N = { "Nzzzv", "Previous result (centered)" }, + J = { "mzJ`z", "Join lines (stable)" }, +}) + +-- visual binds +wk.register({ + J = { ":m '>+1gv=gv", "Move line down" }, + K = { ":m '<-2gv=gv", "Move line up" }, +}, { mode = "v" }) + +-- terminal binds +wk.register({ + [""] = { [[]], "Normal mode" }, +}, { mode = "t" }) + +-- normal + terminal binds +wk.register({ + [""] = { "wincmd h", "Go to the left window" }, + [""] = { "wincmd j", "Go to the down window" }, + [""] = { "wincmd k", "Go to the up window" }, + [""] = { "wincmd l", "Go to the right window" }, +}, { mode = { "n", "t" } }) + +-- leader binds +wk.register({ + p = { [["+p]], "Put from clipboard" }, + w = { [[:w]], "Quick Save" }, + q = { [[:q]], "Quick Exit" }, +}, { prefix = "" }) + +-- nv leader binds +wk.register({ + d = { [["_d]], "Delete w/o yank" }, + y = { [["+y]], "Yank to clipboard" }, +}, { prefix = "", mode = { "n", "v" } }) + +-- x leader binds +wk.register({ + p = { [["_dP"]], "Put w/o yank" }, +}, { prefix = "", mode = "x" }) diff --git a/dot_config/nvim/lua/options.lua b/dot_config/nvim/lua/options.lua new file mode 100644 index 0000000..887aaef --- /dev/null +++ b/dot_config/nvim/lua/options.lua @@ -0,0 +1,54 @@ +-- puts current line number on current line +-- relative line numbers on everything else +vim.opt.number = true +vim.opt.relativenumber = true + +-- default to 4 spaces for indentation +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.expandtab = true + +-- keep some lines at the top/bottom of the window +vim.opt.scrolloff = 8 + +-- smarter smartindent +vim.opt.cindent = true + +-- global statusline +vim.opt.laststatus = 3 + +-- apparently this makes cmp work +vim.opt.completeopt = "menu,menuone,noselect" + +-- no more jumping around when signs arrive +vim.opt.signcolumn = "yes" + +-- live life dangerously +vim.opt.swapfile = true +vim.opt.backup = true +vim.opt.undofile = true +vim.opt.undodir = vim.fn.stdpath("data") .. "/undo/" +vim.opt.backupdir = vim.fn.stdpath("data") .. "/backup/" +vim.opt.directory = vim.fn.stdpath("data") .. "/swap/" + +-- no more noh and incremental search highlighting +vim.opt.hlsearch = false +vim.opt.incsearch = true + +-- make cursorhold happen faster +vim.opt.updatetime = 100 + +-- make which key show up faster +vim.opt.timeoutlen = 500 + +-- 24bit tui colours +vim.opt.termguicolors = true + +-- gui/neovide stuff +vim.opt.guifont = "Fantasque Sans Mono:h13" + +if vim.g.neovide then + vim.g.neovide_cursor_vfx_mode = "pixiedust" + vim.g.neovide_cursor_vfx_particle_density = 50 +end diff --git a/dot_config/nvim/lua/plugins/asciiblocks.lua b/dot_config/nvim/lua/plugins/asciiblocks.lua new file mode 100644 index 0000000..9e820d6 --- /dev/null +++ b/dot_config/nvim/lua/plugins/asciiblocks.lua @@ -0,0 +1,3 @@ +return { + { "superhawk610/ascii-blocks.nvim", cmd = "AsciiBlockify" }, +} diff --git a/dot_config/nvim/lua/plugins/asciitree.lua b/dot_config/nvim/lua/plugins/asciitree.lua new file mode 100644 index 0000000..f991b24 --- /dev/null +++ b/dot_config/nvim/lua/plugins/asciitree.lua @@ -0,0 +1,3 @@ +return { + { "cloudysake/asciitree.nvim", cmd = "AsciiTree" }, +} diff --git a/dot_config/nvim/lua/plugins/autopairs.lua b/dot_config/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..5a4f009 --- /dev/null +++ b/dot_config/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,16 @@ +return { + { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup({ + disable_in_macro = true, + }) + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require('cmp') + cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() + ) + end, + }, +} diff --git a/dot_config/nvim/lua/plugins/catppuccin.lua b/dot_config/nvim/lua/plugins/catppuccin.lua new file mode 100644 index 0000000..5918b17 --- /dev/null +++ b/dot_config/nvim/lua/plugins/catppuccin.lua @@ -0,0 +1,58 @@ +return { + { + "catppuccin/nvim", + name = "catppuccin", + lazy = false, + priority = 1000, + config = function() + local cp = require("catppuccin.palettes").get_palette() + + require("catppuccin").setup({ + flavour = "mocha", + transparent_background = true, + term_colors = true, + no_italic = true, + integrations = { + mason = true, + native_lsp = { enabled = true }, + navic = { + enabled = true, + custom_bg = "NONE", + }, + noice = true, + notify = true, + dap = { + enabled = true, + enable_ui = true, + }, + cmp = true, + treesitter = true, + overseer = true, + telescope = true, + which_key = true, + }, + color_overrides = { + mocha = { + base = "#000000", + mantle = "#000000", + surface2 = cp.subtext0, + overlay0 = cp.subtext0, + }, + }, + custom_highlights = { + ErrorMsg = { fg = cp.red, style = { "bold" } }, + LspInfoBorder = { link = "FloatBorder" }, + PmenuSel = { bg = cp.surface0 }, + FloatBorder = { fg = cp.overlay0, bg = "NONE" }, + TelescopeBorder = { link = "FloatBorder" }, + TelescopeMatching = { link = "TelescopeNormal" }, + TelescopeSelection = { fg = "NONE", bg = cp.surface0 }, + TelescopeTitle = { fg = cp.subtext0 }, + QuickScopePrimary = { fg = cp.maroon }, + QuickScopeSecondary = { fg = cp.peach }, + }, + }) + vim.cmd.colorscheme("catppuccin") + end, + }, +} diff --git a/dot_config/nvim/lua/plugins/ccc.lua b/dot_config/nvim/lua/plugins/ccc.lua new file mode 100644 index 0000000..7d5ee27 --- /dev/null +++ b/dot_config/nvim/lua/plugins/ccc.lua @@ -0,0 +1,3 @@ +return { + { "uga-rosa/ccc.nvim", config = { highlighter = { auto_enable = true } } }, +} diff --git a/dot_config/nvim/lua/plugins/cmp.lua b/dot_config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..2a5c735 --- /dev/null +++ b/dot_config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,110 @@ +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 + +return { + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + local cmp_under_comparator = require("cmp-under-comparator") + local lspkind = require("lspkind") + local luasnip = require("luasnip") + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete({}), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.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 luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + { name = "path" }, + }), + sorting = { + comparators = { + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + cmp_under_comparator.under, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + }, + formatting = { + format = lspkind.cmp_format({ + mode = "symbol", + maxwidth = 30, + ellipsis_char = "…", + }), + }, + }) + + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + end, + dependencies = { + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + "L3MON4D3/LuaSnip", + "lukas-reineke/cmp-under-comparator", + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/cmp.lua~ b/dot_config/nvim/lua/plugins/cmp.lua~ new file mode 100644 index 0000000..5cbad55 --- /dev/null +++ b/dot_config/nvim/lua/plugins/cmp.lua~ @@ -0,0 +1,95 @@ +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 + +return { + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + local cmp_under_comparator = require("cmp-under-comparator") + local lspkind = require("lspkind") + local luasnip = require("luasnip") + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete({}), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.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 luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + }), + formatting = { + format = lspkind.cmp_format({ + mode = "symbol", + maxwidth = 30, + ellipsis_char = "…", + }), + }, + }) + + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + end, + dependencies = { + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + "L3MON4D3/LuaSnip", + "lukas-reineke/cmp-under-comparator", + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/comment.lua b/dot_config/nvim/lua/plugins/comment.lua new file mode 100644 index 0000000..fbe10c1 --- /dev/null +++ b/dot_config/nvim/lua/plugins/comment.lua @@ -0,0 +1,3 @@ +return { + { "numToStr/Comment.nvim", config = true }, +} diff --git a/dot_config/nvim/lua/plugins/coverage.lua b/dot_config/nvim/lua/plugins/coverage.lua new file mode 100644 index 0000000..5558514 --- /dev/null +++ b/dot_config/nvim/lua/plugins/coverage.lua @@ -0,0 +1,7 @@ +return { + { + "andythigpen/nvim-coverage", + config = true, + dependencies = { "nvim-lua/plenary.nvim" }, + }, +} diff --git a/dot_config/nvim/lua/plugins/dap.lua b/dot_config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..3aae04d --- /dev/null +++ b/dot_config/nvim/lua/plugins/dap.lua @@ -0,0 +1,82 @@ +local get_python_path = function() + for _, client in pairs(vim.lsp.buf_get_clients()) do + if client.name == "pyright" then + local path = client.config.settings.python.pythonPath + if path ~= nil then + return path + else + return "python" + end + end + end +end + +return { + { + "jayp0521/mason-nvim-dap.nvim", + config = function() + local dap = require("dap") + local mason_dap = require("mason-nvim-dap") + + mason_dap.setup({ + ensure_installed = { "python", "codelldb" }, + automatic_setup = true, + }) + mason_dap.setup_handlers({ + -- default handler + function(source) + require("mason-nvim-dap.automatic_setup")(source) + end, + + -- custom handlers + python = function(_) + dap.adapters.python = { + type = "executable", + command = "debugpy-adapter", + } + + dap.configurations.python = { + { + name = "Launch current file", + type = "python", + request = "launch", + program = "${file}", + pythonPath = get_python_path, + }, + { + name = "Launch pytest", + type = "python", + request = "launch", + module = "pytest", + pythonPath = get_python_path, + }, + } + end, + }) + + -- apply suggestions from catppuccin theme + local sign = vim.fn.sign_define + + sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" }) + sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = "" }) + sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = "" }) + end, + keys = { + { "xb", vim.cmd.DapToggleBreakpoint, desc = "Toggle breakpoint" }, + { + "xu", + function() + require("dapui").toggle({}) + end, + desc = "Toggle UI", + }, + { "xx", vim.cmd.DapContinue, desc = "Start / Continue" }, + }, + dependencies = { + "williamboman/mason.nvim", + "mfussenegger/nvim-dap", + { "rcarriga/nvim-dap-ui", config = true }, + { "theHamsta/nvim-dap-virtual-text", config = true }, + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/delaytrain.lua b/dot_config/nvim/lua/plugins/delaytrain.lua new file mode 100644 index 0000000..f03ac4c --- /dev/null +++ b/dot_config/nvim/lua/plugins/delaytrain.lua @@ -0,0 +1,9 @@ +return { + { + "ja-ford/delaytrain.nvim", + config = { + grace_period = 3, + ignore_filetypes = {"help", "NvimTr*", "toggleterm"} + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/feline.lua b/dot_config/nvim/lua/plugins/feline.lua new file mode 100644 index 0000000..8cf8d72 --- /dev/null +++ b/dot_config/nvim/lua/plugins/feline.lua @@ -0,0 +1,14 @@ +return { + { + "feline-nvim/feline.nvim", + config = function() + local feline = require("feline") + local ctp_feline = require("catppuccin.groups.integrations.feline") + + -- catppuccin statusline + ctp_feline.setup({}) + feline.setup({ components = ctp_feline.get() }) + end, + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, +} diff --git a/dot_config/nvim/lua/plugins/init.lua b/dot_config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..0acead5 --- /dev/null +++ b/dot_config/nvim/lua/plugins/init.lua @@ -0,0 +1,8 @@ +-- misc plugins +return { + { "kana/vim-textobj-entire", dependencies = { "kana/vim-textobj-user" } }, + "kevinhwang91/nvim-bqf", + "stevearc/dressing.nvim", + "mong8se/actually.nvim", + "andweeb/presence.nvim", +} diff --git a/dot_config/nvim/lua/plugins/lsp.lua b/dot_config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..585650f --- /dev/null +++ b/dot_config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,189 @@ +local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end + +vim.diagnostic.config({ + float = { border = "rounded" }, + update_in_insert = true, +}) +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) + +local default_config = { + on_attach = function(client, bufnr) + require("lsp-format").on_attach(client) + + -- add lsp-only keybinds + local map = function(sequence, cmd, desc) + vim.keymap.set("n", sequence, cmd, { buffer = bufnr, desc = desc }) + end + + map("gd", function() + require("telescope.builtin").lsp_definitions() + end, "LSP Definitions") + map("gr", function() + require("telescope.builtin").lsp_references() + end, "LSP References") + map("gI", function() + require("telescope.builtin").lsp_implementations() + end, "LSP Implementations") + map("K", vim.lsp.buf.hover, "Hover") + map("]d", vim.diagnostic.goto_next, "Next diagnostic") + map("[d", vim.diagnostic.goto_prev, "Previous diagnostic") + -- add git signs later + + map("la", vim.lsp.buf.code_action, "Code Action") + map("lr", vim.lsp.buf.rename, "Rename") + map("lf", vim.lsp.buf.format, "Format") + map("lw", function() + require("telescope.builtin").diagnostics() + end, "LSP Workplace Diagnostics") + map("ld", function() + require("telescope.builtin").diagnostics({ + bufnr = 0, + }) + end, "LSP Buffer Diagnostics") + map("ls", function() + require("telescope.builtin").lsp_document_symbols() + end, "LSP Document Symbols") + map("lS", function() + require("telescope.builtin").lsp_workspace_symbols() + end, "LSP Workplace Symbols") + end, +} + +local custom_config = function(config) + local merged_config = vim.deepcopy(default_config) + merged_config = vim.tbl_extend("force", merged_config, config) + return merged_config +end + +return { + { + "neovim/nvim-lspconfig", + config = function() + require("lspconfig.ui.windows").default_options.border = "rounded" + end, + dependencies = { + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { "rust_analyzer", "pyright", "sumneko_lua" }, + }) + require("mason-lspconfig").setup_handlers({ + -- default handler + function(server_name) + require("lspconfig")[server_name].setup(default_config) + end, + ["rust_analyzer"] = function() + -- https://github.com/simrat39/rust-tools.nvim/issues/300 + local config = custom_config({ + settings = { + ["rust-analyzer"] = { + inlayHints = { locationLinks = false }, + }, + }, + }) + require("rust-tools").setup({ + server = config, + dap = { + adapter = { + type = "server", + port = "${port}", + host = "127.0.0.1", + executable = { + command = "codelldb", + args = { "--port", "${port}" }, + }, + }, + }, + }) + end, + ["pyright"] = function() + require("py_lsp").setup(default_config) + end, + ["hls"] = function() + local ht = require("haskell-tools") + local def_opts = { noremap = true, silent = true } + ht.setup({ + hls = { + on_attach = function(client, bufnr) + local opts = vim.tbl_extend("keep", def_opts, { buffer = bufnr }) + -- haskell-language-server relies heavily on codeLenses, + -- so auto-refresh (see advanced configuration) is enabled by default + vim.keymap.set("n", "ca", vim.lsp.codelens.run, opts) + vim.keymap.set("n", "hs", ht.hoogle.hoogle_signature, opts) + end, + }, + }) + -- Suggested keymaps that do not depend on haskell-language-server + -- Toggle a GHCi repl for the current package + vim.keymap.set("n", "rr", ht.repl.toggle, def_opts) + -- Toggle a GHCi repl for the current buffer + vim.keymap.set("n", "rf", function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) + end, def_opts) + vim.keymap.set("n", "rq", ht.repl.quit, def_opts) + end, + ["sumneko_lua"] = function() + require("lspconfig")["sumneko_lua"].setup(custom_config({ + settings = { + Lua = { + format = { + enable = false, + }, + workspace = { + checkThirdParty = false, + }, + telemetry = { + enable = false, + }, + }, + }, + })) + end, + }) + end, + dependencies = { + "williamboman/mason.nvim", + { "folke/neodev.nvim", config = true }, + }, + }, + "simrat39/rust-tools.nvim", + "mrcjkb/haskell-tools.nvim", + "HallerPatrick/py_lsp.nvim", + { "SmiteshP/nvim-navic", config = { highlight = true } }, + "onsails/lspkind.nvim", + { "lukas-reineke/lsp-format.nvim", config = true }, + "folke/neodev.nvim", + "ray-x/lsp_signature.nvim", + }, + }, + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + local null_ls = require("null-ls") + null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua.with({ + extra_args = { "--indent-type", "spaces" }, + }), + -- null_ls.builtins.formatting.black, + -- null_ls.builtins.formatting.isort.with({ + -- extra_args = { "--profile", "black" }, + -- }), + }, + }) + end, + dependencies = { "nvim-lua/plenary.nvim" }, + }, + { + "jay-babu/mason-null-ls.nvim", + config = { + ensure_installed = { "stylua" }, + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/mason.lua b/dot_config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..9a4bd0f --- /dev/null +++ b/dot_config/nvim/lua/plugins/mason.lua @@ -0,0 +1,6 @@ +return { + { + "williamboman/mason.nvim", + config = { ui = { border = "rounded" } }, + } +} diff --git a/dot_config/nvim/lua/plugins/mini.lua b/dot_config/nvim/lua/plugins/mini.lua new file mode 100644 index 0000000..a3a7d48 --- /dev/null +++ b/dot_config/nvim/lua/plugins/mini.lua @@ -0,0 +1,18 @@ +return { + { + "echasnovski/mini.nvim", + config = function() + -- add gc/gcc actions, gc textobject + require("mini.comment").setup({}) + + -- highlight word under cursor + require("mini.cursorword").setup({ delay = 0 }) + + -- indent lines, `i` textobject, `]i`/`[i` motions + require("mini.indentscope").setup({ + draw = { delay = 0 }, + symbol = "│", + }) + end, + } +} diff --git a/dot_config/nvim/lua/plugins/netrw.lua b/dot_config/nvim/lua/plugins/netrw.lua new file mode 100644 index 0000000..f540f95 --- /dev/null +++ b/dot_config/nvim/lua/plugins/netrw.lua @@ -0,0 +1,3 @@ +return { + { "prichrd/netrw.nvim", config = true }, +} diff --git a/dot_config/nvim/lua/plugins/noice.lua b/dot_config/nvim/lua/plugins/noice.lua new file mode 100644 index 0000000..469caac --- /dev/null +++ b/dot_config/nvim/lua/plugins/noice.lua @@ -0,0 +1,35 @@ +return { + -- disabled until https://github.com/folke/noice.nvim/issues/298 is fixed + -- { + -- "folke/noice.nvim", + -- config = { + -- lsp = { + -- progress = { enabled = false }, + -- + -- -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + -- override = { + -- ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + -- ["vim.lsp.util.stylize_markdown"] = true, + -- ["cmp.entry.get_documentation"] = true, + -- }, + -- }, + -- -- you can enable a preset for easier configuration + -- presets = { + -- bottom_search = true, + -- long_message_to_split = true, + -- lsp_doc_border = true, + -- }, + -- }, + -- dependencies = { + -- "MunifTanjim/nui.nvim", + -- { + -- "rcarriga/nvim-notify", + -- config = { + -- background_colour = require("catppuccin.palettes").get_palette("mocha").base, + -- render = "minimal", + -- top_down = false, + -- }, + -- }, + -- }, + -- }, +} diff --git a/dot_config/nvim/lua/plugins/overseer.lua b/dot_config/nvim/lua/plugins/overseer.lua new file mode 100644 index 0000000..5eb95db --- /dev/null +++ b/dot_config/nvim/lua/plugins/overseer.lua @@ -0,0 +1,11 @@ +return { + { + "stevearc/overseer.nvim", + config = true, + cmd = { "OverseerRun", "OverseerToggle" }, + keys = { + { "tr", vim.cmd.OverseerRun, desc = "Run Task" }, + { "tt", vim.cmd.OverseerToggle, desc = "Toggle task results" }, + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/quickscope.lua b/dot_config/nvim/lua/plugins/quickscope.lua new file mode 100644 index 0000000..6dbebfc --- /dev/null +++ b/dot_config/nvim/lua/plugins/quickscope.lua @@ -0,0 +1,8 @@ +return { + { + "unblevable/quick-scope", + init = function() + vim.g.qs_highlight_on_keys = { "f", "F", "t", "T" } + end, + }, +} diff --git a/dot_config/nvim/lua/plugins/searchreplace.lua b/dot_config/nvim/lua/plugins/searchreplace.lua new file mode 100644 index 0000000..4b73962 --- /dev/null +++ b/dot_config/nvim/lua/plugins/searchreplace.lua @@ -0,0 +1,8 @@ +return { + { + "roobert/search-replace.nvim", + config = function() + require("search-replace").setup({}) + end, + }, +} diff --git a/dot_config/nvim/lua/plugins/surround.lua b/dot_config/nvim/lua/plugins/surround.lua new file mode 100644 index 0000000..164a33b --- /dev/null +++ b/dot_config/nvim/lua/plugins/surround.lua @@ -0,0 +1,3 @@ +return { + { "kylechui/nvim-surround", config = true }, +} diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..20aa164 --- /dev/null +++ b/dot_config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,28 @@ +return { + { + "nvim-telescope/telescope.nvim", + config = function() + require("telescope").load_extension("fzy_native") + require("telescope").load_extension("catppuccin") + require("telescope").load_extension("smart_open") + end, + keys = { + -- { "fg", "Telescope git_files", "Git files" }, + { "ff", "Telescope smart_open", "Find files" }, + { "fr", "Telescope oldfiles", "Recent Files" }, + { "fg", "Telescope live_grep", "Live grep" }, + { "fc", "Telescope catppuccin", "Catppuccin Colours" }, + { "fj", "Telescope jumplist", "Jumplist" }, + }, + cmd = "Telescope", + dependencies = { + "backwardspy/telescope-catppuccin.nvim", + { + "nvim-telescope/telescope-fzy-native.nvim", + dependencies = { "kkharji/sqlite.lua" }, + }, + "danielfalk/smart-open.nvim", + "backwardspy/telescope-catppuccin.nvim", + }, + }, +} diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..bef1cf3 --- /dev/null +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,40 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = function() + local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) + ts_update() + end, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = "all", + highlight = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + scope_incremental = "", + node_incremental = "", + node_decremental = "", + }, + }, + indent = { enable = false }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + }, + }, + }, + }) + end, + dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" }, + }, +} diff --git a/dot_config/nvim/lua/plugins/which_key.lua b/dot_config/nvim/lua/plugins/which_key.lua new file mode 100644 index 0000000..ad94c3f --- /dev/null +++ b/dot_config/nvim/lua/plugins/which_key.lua @@ -0,0 +1,31 @@ +return { + { + "folke/which-key.nvim", + config = function() + local wk = require("which-key") + wk.setup({ + window = { + border = "rounded", + }, + }) + + wk.register({ + g = { name = "Go to" }, + ["]"] = { name = "Next" }, + ["["] = { name = "Previous" }, + }) + + wk.register({ + c = { name = "Code" }, + f = { name = "Find" }, + g = { name = "Git" }, + j = { name = "Jump" }, + l = { name = "LSP" }, + o = { name = "Open" }, + s = { name = "Search" }, + t = { name = "Tasks" }, + x = { name = "Debug" }, + }, { prefix = "" }) + end, + }, +} diff --git a/dot_config/nvim/lua/plugins/zenmode.lua b/dot_config/nvim/lua/plugins/zenmode.lua new file mode 100644 index 0000000..bd6793a --- /dev/null +++ b/dot_config/nvim/lua/plugins/zenmode.lua @@ -0,0 +1,20 @@ +local extremely_zen = function() + require("zen-mode").toggle({ plugins = { twilight = { enabled = true } } }) +end + +return { + { + "folke/zen-mode.nvim", + opts = { + plugins = { + twilight = { enabled = false }, + }, + }, + cmd = { "ZenMode" }, + keys = { + { "zz", "ZenMode", desc = "Zen Mode" }, + { "Z", extremely_zen, desc = "Extremely Zen Mode" }, + }, + dependencies = { "folke/twilight.nvim" }, + }, +}