From 66f3983c1af82d46d694434f4171100f106a8432 Mon Sep 17 00:00:00 2001 From: Ryan El Kochta Date: Thu, 27 Feb 2025 11:49:14 -0500 Subject: [PATCH] Initial commit --- .gitignore | 1 + init.lua | 2 + lazy-lock.json | 44 +++++++++ lua/core/config.lua | 24 +++++ lua/core/init.lua | 5 + lua/core/lazy.lua | 24 +++++ lua/core/neovide.lua | 4 + lua/core/remap.lua | 7 ++ lua/core/theme.lua | 9 ++ lua/plugins/bufferline.lua | 37 ++++++++ lua/plugins/git.lua | 11 +++ lua/plugins/illuminate.lua | 22 +++++ lua/plugins/indent.lua | 49 ++++++++++ lua/plugins/lang/bash.lua | 10 ++ lua/plugins/lang/c.lua | 15 +++ lua/plugins/lang/go.lua | 10 ++ lua/plugins/lang/js.lua | 8 ++ lua/plugins/lang/python.lua | 10 ++ lua/plugins/lang/racket.lua | 10 ++ lua/plugins/lang/rust.lua | 52 +++++++++++ lua/plugins/lang/tex.lua | 50 ++++++++++ lua/plugins/lsp.lua | 175 +++++++++++++++++++++++++++++++++++ lua/plugins/lualine.lua | 34 +++++++ lua/plugins/neorg.lua | 54 +++++++++++ lua/plugins/neotree.lua | 41 ++++++++ lua/plugins/numbertoggle.lua | 5 + lua/plugins/pairs.lua | 7 ++ lua/plugins/sleuth.lua | 5 + lua/plugins/splitjoin.lua | 16 ++++ lua/plugins/telescope.lua | 56 +++++++++++ lua/plugins/theme.lua | 20 ++++ lua/plugins/treesitter.lua | 15 +++ lua/plugins/ui.lua | 60 ++++++++++++ lua/plugins/whichkey.lua | 15 +++ snippets/tex.snippets | 6 ++ 35 files changed, 913 insertions(+) create mode 100644 .gitignore create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/core/config.lua create mode 100644 lua/core/init.lua create mode 100644 lua/core/lazy.lua create mode 100644 lua/core/neovide.lua create mode 100644 lua/core/remap.lua create mode 100644 lua/core/theme.lua create mode 100644 lua/plugins/bufferline.lua create mode 100644 lua/plugins/git.lua create mode 100644 lua/plugins/illuminate.lua create mode 100644 lua/plugins/indent.lua create mode 100644 lua/plugins/lang/bash.lua create mode 100644 lua/plugins/lang/c.lua create mode 100644 lua/plugins/lang/go.lua create mode 100644 lua/plugins/lang/js.lua create mode 100644 lua/plugins/lang/python.lua create mode 100644 lua/plugins/lang/racket.lua create mode 100644 lua/plugins/lang/rust.lua create mode 100644 lua/plugins/lang/tex.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/neorg.lua create mode 100644 lua/plugins/neotree.lua create mode 100644 lua/plugins/numbertoggle.lua create mode 100644 lua/plugins/pairs.lua create mode 100644 lua/plugins/sleuth.lua create mode 100644 lua/plugins/splitjoin.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/theme.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/ui.lua create mode 100644 lua/plugins/whichkey.lua create mode 100644 snippets/tex.snippets diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43cbc06 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/spell diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..8371ef7 --- /dev/null +++ b/init.lua @@ -0,0 +1,2 @@ +require("core") + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..527f63a --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,44 @@ +{ + "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, + "bufferline.nvim": { "branch": "main", "commit": "17083c826a004bcb87d3a830c7710d0796a73bbf" }, + "catppuccin": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "crates.nvim": { "branch": "main", "commit": "bd35b13e94a292ee6e32c351e05ca2202dc9f070" }, + "diagflow.nvim": { "branch": "main", "commit": "fc09d55d2e60edc8ed8f9939ba97b7b7e6488c99" }, + "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, + "gitsigns.nvim": { "branch": "main", "commit": "abcd00a7d5bc1a9470cb21b023c575acade3e4db" }, + "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, + "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "ab2a3413646fedd77aa0eab4214a6473e62f6a64" }, + "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mini.bufremove": { "branch": "main", "commit": "285bdac9596ee7375db50c0f76ed04336dcd2685" }, + "mini.icons": { "branch": "main", "commit": "1c79feb7478ca773fa3dac5cadf43ced9180e861" }, + "mini.indentscope": { "branch": "main", "commit": "da9af64649e114aa79480c238fd23f6524bc0903" }, + "mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" }, + "mini.splitjoin": { "branch": "main", "commit": "3e92f6764e770ba392325cad3a4497adcada695f" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "e6645ecfcba3e064446a6def1c10d788c9873f51" }, + "neorg": { "branch": "main", "commit": "4cbedbbdd4ccb6f45a2045477f5658a1311dffa3" }, + "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, + "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, + "nvim-cmp": { "branch": "main", "commit": "8c82d0bd31299dbff7f8e780f5e06d2283de9678" }, + "nvim-lspconfig": { "branch": "master", "commit": "88157521e890fe7fdf18bee22438875edd6300a6" }, + "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, + "nvim-treesitter": { "branch": "master", "commit": "097fb77312c731347180e8907424f6c967323f05" }, + "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, + "nvim-web-devicons": { "branch": "master", "commit": "aafa5c187a15701a7299a392b907ec15d9a7075f" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, + "ripgrep": { "branch": "master", "commit": "94305125ef33b86151b6cd2ce2b33d641f6b6ac3" }, + "telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, + "vim-fugitive": { "branch": "master", "commit": "174230d6a7f2df94705a7ffd8d5413e27ec10a80" }, + "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, + "vim-lumen": { "branch": "master", "commit": "ac13c32c3e309f6c6a84ff6cad8dbb135e75f0e4" }, + "vim-numbertoggle": { "branch": "main", "commit": "075b7478777e694fbac330ee34a74590dad0fee1" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vimtex": { "branch": "master", "commit": "adce3d38349925a0a891857c74bd4e8d1b8f80ab" }, + "which-key.nvim": { "branch": "main", "commit": "1f8d414f61e0b05958c342df9b6a4c89ce268766" } +} diff --git a/lua/core/config.lua b/lua/core/config.lua new file mode 100644 index 0000000..58b6784 --- /dev/null +++ b/lua/core/config.lua @@ -0,0 +1,24 @@ +-- Cursorline +vim.o.cursorline = true + +-- 4 space indent (by default) +vim.o.tabstop = 4 +vim.o.expandtab = true +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 + +-- Relative line numbers +vim.o.number = true +vim.o.relativenumber = true + +-- Disable word wrap +vim.o.wrap = false + +-- Split to right & below +vim.o.splitright = true +vim.o.splitbelow = true + +-- Use American English +vim.o.spelllang = "en_us" +--vim.o.spellcapcheck = false + diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..bf1c460 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,5 @@ +require("core.remap") +require("core.lazy") +require("core.theme") +require("core.config") +require("core.neovide") diff --git a/lua/core/lazy.lua b/lua/core/lazy.lua new file mode 100644 index 0000000..d98009a --- /dev/null +++ b/lua/core/lazy.lua @@ -0,0 +1,24 @@ +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) + +-- lazy.nvim configuration +local plugins_dir = "plugins" +local opts = { + -- disable change detection because it's annoying + change_detection = { + enabled = false, + notify = false, + }, +} + +require("lazy").setup(plugins_dir, opts) diff --git a/lua/core/neovide.lua b/lua/core/neovide.lua new file mode 100644 index 0000000..22cc9c2 --- /dev/null +++ b/lua/core/neovide.lua @@ -0,0 +1,4 @@ +if vim.g.neovide then + vim.o.guifont = "IosevkaTerm Nerd Font:h14" + vim.g.neovide_floating_shadow = false +end diff --git a/lua/core/remap.lua b/lua/core/remap.lua new file mode 100644 index 0000000..0e06f07 --- /dev/null +++ b/lua/core/remap.lua @@ -0,0 +1,7 @@ +-- Space as leader key +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- U as redo (not sure why this doesn't work by default?) +vim.api.nvim_set_keymap('n', 'U', '', { noremap = true }) + diff --git a/lua/core/theme.lua b/lua/core/theme.lua new file mode 100644 index 0000000..34b415b --- /dev/null +++ b/lua/core/theme.lua @@ -0,0 +1,9 @@ +-- Set colorscheme to dracula +vim.cmd[[colorscheme catppuccin]] + +-- Enable for lualine as well +require("lualine").setup { + options = { + theme = "catppuccin", + } +} diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 0000000..4014f98 --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,37 @@ +return { + { + "echasnovski/mini.bufremove", + version = false, + event = "VeryLazy", + opts = {}, + }, + { + "akinsho/bufferline.nvim", + event = "VeryLazy", + keys = { + { "gn", "BufferLineCycleNext", desc = "Go to next buffer", }, + { "gp", "BufferLineCyclePrev", desc = "Go to previous buffer", }, + }, + opts = { + options = { + -- fix bug with neotree causing closing tab to close editor + close_command = function(n) require("mini.bufremove").delete() end, + right_mouse_command = function(n) require("mini.bufremove").delete() end, + --always_show_bufferline = false, + diagnostics = "nvim_lsp", + offsets = { -- From LazyVim; don't show above NeoTree + { + filetype = "neo-tree", + text = "Neo-tree", + highlight = "Directory", + text_align = "left", + }, + }, + } + }, + }, + { + "nvim-tree/nvim-web-devicons", + lazy = true + }, +} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..118a914 --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,11 @@ +return { + { + "lewis6991/gitsigns.nvim", + event = "VeryLazy", + opts = {}, + }, + { + "tpope/vim-fugitive", + cmd = "Git", + }, +} diff --git a/lua/plugins/illuminate.lua b/lua/plugins/illuminate.lua new file mode 100644 index 0000000..70fd4d9 --- /dev/null +++ b/lua/plugins/illuminate.lua @@ -0,0 +1,22 @@ +return { + { + "RRethy/vim-illuminate", + event = "VeryLazy", + opts = { + delay = 200, + large_file_cutoff = 2000, + large_file_overrides = { + providers = { "lsp" }, + }, + filetypes_denylist = { + "neo-tree", + 'dirbuf', + 'dirvish', + 'fugitive', + }, + }, + config = function(_, opts) + require("illuminate").configure(opts) + end, + } +} diff --git a/lua/plugins/indent.lua b/lua/plugins/indent.lua new file mode 100644 index 0000000..34329ff --- /dev/null +++ b/lua/plugins/indent.lua @@ -0,0 +1,49 @@ +local indent_exclude_filetypes = { + "help", + "alpha", + "dashboard", + "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", +} + +return { + { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + event = "VeryLazy", + opts = { + indent = { + char = "│", + tab_char = "│", + }, + scope = { enabled = false }, + exclude = { + filetypes = indent_exclude_filetypes, + }, + }, + }, + { + "echasnovski/mini.indentscope", + event = "VeryLazy", + opts = { + -- symbol = "▏", + symbol = "│", + options = { try_as_border = true }, + }, + init = function() + vim.api.nvim_create_autocmd("FileType", { + pattern = indent_exclude_filetypes, + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + end, + } +} + diff --git a/lua/plugins/lang/bash.lua b/lua/plugins/lang/bash.lua new file mode 100644 index 0000000..72926fc --- /dev/null +++ b/lua/plugins/lang/bash.lua @@ -0,0 +1,10 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + opts = { + my_servers = { + bashls = {}, + }, + }, + }, +} diff --git a/lua/plugins/lang/c.lua b/lua/plugins/lang/c.lua new file mode 100644 index 0000000..0ed56fd --- /dev/null +++ b/lua/plugins/lang/c.lua @@ -0,0 +1,15 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + opts = { + my_servers = { + clangd = { + cmd = { + "clangd", + "--function-arg-placeholders=0", + }, + }, + }, + }, + }, +} diff --git a/lua/plugins/lang/go.lua b/lua/plugins/lang/go.lua new file mode 100644 index 0000000..dbfb57b --- /dev/null +++ b/lua/plugins/lang/go.lua @@ -0,0 +1,10 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + opts = { + my_servers = { + gopls = {}, + }, + }, + }, +} diff --git a/lua/plugins/lang/js.lua b/lua/plugins/lang/js.lua new file mode 100644 index 0000000..293cc76 --- /dev/null +++ b/lua/plugins/lang/js.lua @@ -0,0 +1,8 @@ +return { + { + "windwp/nvim-ts-autotag", + event = "VeryLazy", + opts = {}, + }, +} + diff --git a/lua/plugins/lang/python.lua b/lua/plugins/lang/python.lua new file mode 100644 index 0000000..8bd9d16 --- /dev/null +++ b/lua/plugins/lang/python.lua @@ -0,0 +1,10 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + opts = { + my_servers = { + pylsp = {}, + }, + }, + }, +} diff --git a/lua/plugins/lang/racket.lua b/lua/plugins/lang/racket.lua new file mode 100644 index 0000000..4d485e3 --- /dev/null +++ b/lua/plugins/lang/racket.lua @@ -0,0 +1,10 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + opts = { + my_servers = { + racket_langserver = {}, + }, + }, + }, +} diff --git a/lua/plugins/lang/rust.lua b/lua/plugins/lang/rust.lua new file mode 100644 index 0000000..615fbbc --- /dev/null +++ b/lua/plugins/lang/rust.lua @@ -0,0 +1,52 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + opts = { + my_servers = { + rust_analyzer = { + settings = { + ['rust-analyzer'] = { + completion = { + callable = { + snippets = "add_parentheses", + }, + }, + } + } + }, + }, + }, + }, + { + "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + dependencies = { + { + "hrsh7th/nvim-cmp", + opts = function(_, opts) + table.insert(opts.sources, { name = "crates" }) + end, + }, + }, + opts = { + completion = { + cmp = { enabled = true }, + }, + -- locali(z|s)ation + thousands_separator = ",", + }, + config = function(_, opts) + -- K hover keybind + local docs_keybind = function() + if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then + require("crates").show_popup() + else + vim.lsp.buf.hover() + end + end + vim.keymap.set("n", "K", docs_keybind, { desc = "Show documentation" }) + + require("crates").setup(opts) + end, + }, +} diff --git a/lua/plugins/lang/tex.lua b/lua/plugins/lang/tex.lua new file mode 100644 index 0000000..aff45ec --- /dev/null +++ b/lua/plugins/lang/tex.lua @@ -0,0 +1,50 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + opts = { + my_servers = { + texlab = {}, + }, + }, + }, + { + "lervag/vimtex", + lazy = true, + ft = { "tex", "bib" }, + config = function() + -- Block taken from LazyVim; disable conceal for TeX files, and mitigate conflicts + vim.api.nvim_create_autocmd({ "FileType" }, { + group = vim.api.nvim_create_augroup("lazyvim_vimtex_conceal", { clear = true }), + pattern = { "bib", "tex" }, + callback = function() + vim.wo.conceallevel = 2 + end, + }) + vim.g.vimtex_mappings_disable = { ["n"] = { "K" } } -- disable `K` as it conflicts with LSP hover + vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog" + + -- only open quickfix menu on *error*, not warning + vim.g.vimtex_quickfix_open_on_warning = 0 + + -- Tell VimTeX that treesitter is managing syntax highlighting + vim.g.vimtex_syntax_enabled = 0 + + -- Use Zathura instead of Evince + --vim.g.vimtex_view_method = "zathura" + vim.g.vimtex_view_forward_search_on_start = 0 + + -- TeX file-specific options + vim.api.nvim_create_autocmd("FileType", { + pattern = "tex", + callback = function(opts) + -- Enable word wrap + vim.opt_local.wrap = true + vim.opt_local.linebreak = true + + -- Enable spell-check + vim.opt_local.spell = true + end, + }) + end, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..ddb8c98 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,175 @@ +return { + { + "VonHeikemen/lsp-zero.nvim", + branch = "v3.x", + dependencies = { + "neovim/nvim-lspconfig", + "SmiteshP/nvim-navic", + }, + opts = { + -- Servers configured in my_servers will automatically have + -- require("lspconfig")[server].setup(server_opts) called on them + my_servers = {}, + }, + config = function(_, opts) + local lsp_zero = require("lsp-zero") + local lspconfig = require("lspconfig") + + -- enable lsp-zero + lsp_zero.on_attach(function(client, buffnr) + -- set lsp keybinds + -- NOTE: this check is needed since crates.nvim will overwrite "K" + if not vim.fn.mapcheck("K", "n") then + vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Show documentation" }) + end + vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" }) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Go to declaration" }) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Go to implementation" }) + vim.keymap.set("n", "go", vim.lsp.buf.type_definition, { desc = "Go to object type definition" }) + vim.keymap.set("n", "r", vim.lsp.buf.rename, { desc = "Rename symbol under cursor" }) + vim.keymap.set("n", "", vim.lsp.buf.rename, { desc = "Rename symbol under cursor" }) + vim.keymap.set("n", "a", vim.lsp.buf.code_action, { desc = "Open code actions" }) + vim.keymap.set("n", "m", vim.lsp.buf.format, { desc = "Format current file" }) + + -- use telescope for LSP references, etc + vim.keymap.set("n", "gr", "Telescope lsp_references", { buffer = buffnr, desc = "Go to references" }) + + -- Use navic for context hints + if client.supports_method("textDocument/documentSymbol") then + require("nvim-navic").attach(client, buffnr) + end + end) + + -- use pretty icons instead of 'W', 'E', ... + lsp_zero.set_sign_icons({ + error = '✘', + warn = '▲', + hint = '⚑', + info = '»' + }) + + -- disable LSP logging + vim.lsp.set_log_level("off") + + -- Set up language servers + local servers = opts.my_servers + for server, server_opts in pairs(servers) do + require("lspconfig")[server].setup(server_opts) + end + end, + }, + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "onsails/lspkind.nvim", + "L3MON4D3/LuaSnip", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "saadparwaiz1/cmp_luasnip", + }, + opts = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local luasnip_snipmate = require("luasnip.loaders.from_snipmate") + + -- set up snippet engine + luasnip_snipmate.lazy_load() + -- functions for handling and with snippets + -- taken from nvim-cmp docs + local tab_mapping = cmp.mapping(function(fallback) + local has_words_before = function() + unpack = unpack or table.unpack + 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 + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- that way you will only jump inside the snippet region + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }) + local s_tab_mapping = 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" }) + + -- configuration for nvim-cmp + return { + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + }), + mapping = { + -- Use "Enter" for auto completion + [""] = cmp.mapping.confirm({select = false}), + [""] = tab_mapping, + [""] = s_tab_mapping, + }, + window = { + -- Borders around completion window + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + formatting = { + -- Enable lsp-kind for icons in completion window + fields = {'abbr', 'kind', 'menu'}, + -- Formatter taken from LazyVim + format = function(entry, vim_item) + local kind = require("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, + }, + } + end, + }, + { + "dgagn/diagflow.nvim", + event = "LspAttach", + opts = { + scope = "line", + }, + }, + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + cmd = { "Trouble" }, + keys = { + { "d", "Trouble diagnostics toggle filter.buf=0", desc = "Open file diagnostic list" }, + { "D", "Trouble diagnostics toggle", desc = "Open workspace diagnostic list" }, + }, + opts = { + focus = true, + use_diagnostic_signs = true, + keys = { + -- both q and to close trouble + q = "close", + [""] = "close", + }, + }, + }, + + + -- Import language configs + { import = "plugins.lang" }, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..930351c --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,34 @@ +return { + { + "nvim-lualine/lualine.nvim", + dependencies = { + "SmiteshP/nvim-navic", + }, + opts = { + sections = { + lualine_c = { + { "navic" }, + }, + lualine_x = { + "%S", -- showcmd + "encoding", + "fileformat", + "filetype", + } + }, + extensions = { + "neo-tree", + }, + }, + config = function(_, opts) + -- No need to show mode + vim.o.showmode = false + -- Show "showcmd" in lualine + vim.o.showcmdloc = "statusline" + + -- Set up lualine for now; + -- this might be called again to change the theme + require("lualine").setup(opts) + end, + } +} diff --git a/lua/plugins/neorg.lua b/lua/plugins/neorg.lua new file mode 100644 index 0000000..dfd5d1e --- /dev/null +++ b/lua/plugins/neorg.lua @@ -0,0 +1,54 @@ +return { + { + "nvim-neorg/neorg", + version = "v7.0.0", -- pin to pre-luarocks version + build = ":Neorg sync-parsers", + priority = 30, -- should load after treesitter + ft = "norg", + cmd = "Neorg", + keys = { + { "n", "Neorg index", desc = "Open Neorg" }, + { "N", "Neorg return", desc = "Close Neorg" }, + }, + dependencies = { + "nvim-lua/plenary.nvim" + }, + config = function() + require("neorg").setup({ + load = { + ["core.defaults"] = {}, -- Loads default behaviour + ["core.concealer"] = {}, -- Adds pretty icons to your documents + ["core.dirman"] = { -- Manages Neorg workspaces + config = { + workspaces = { + notes = "~/notes", + }, + default_workspace = "notes", + }, + }, + }, + }) + + -- add neorg-specific options + vim.api.nvim_create_autocmd("FileType", { + pattern = "norg", + callback = function() + -- enable word wrap + vim.opt_local.wrap = true + vim.opt_local.linebreak = true + + -- create localleader keybindings + local buf = vim.api.nvim_get_current_buf() + vim.keymap.set("n", + "c", + "Neorg toggle-concealer", + { desc = "Toggle concealer", + buffer = buf, + noremap = false + }) + end, + }) + end, + }, +} + diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua new file mode 100644 index 0000000..2fcae11 --- /dev/null +++ b/lua/plugins/neotree.lua @@ -0,0 +1,41 @@ +return { + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + }, + keys = { + { + "e", + function() + require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() }) + end, + desc = "Open file explorer", + }, + }, + opts = { + open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", }, -- From LazyVim + close_if_last_window = true, + window = { + width = 30, + mappings = { + [""] = "none", + }, + }, + }, + init = function() + -- Load instead of netrw + if vim.fn.argc(-1) == 1 then + local stat = vim.loop.fs_stat(vim.fn.argv(0)) + if stat and stat.type == "directory" then + require("neo-tree") + end + end + end, + }, +} + diff --git a/lua/plugins/numbertoggle.lua b/lua/plugins/numbertoggle.lua new file mode 100644 index 0000000..1375642 --- /dev/null +++ b/lua/plugins/numbertoggle.lua @@ -0,0 +1,5 @@ +return { + { + "jeffkreeftmeijer/vim-numbertoggle", + }, +} diff --git a/lua/plugins/pairs.lua b/lua/plugins/pairs.lua new file mode 100644 index 0000000..9a80677 --- /dev/null +++ b/lua/plugins/pairs.lua @@ -0,0 +1,7 @@ +return { + { + "echasnovski/mini.pairs", + event = "VeryLazy", + opts = {}, + } +} diff --git a/lua/plugins/sleuth.lua b/lua/plugins/sleuth.lua new file mode 100644 index 0000000..688a55d --- /dev/null +++ b/lua/plugins/sleuth.lua @@ -0,0 +1,5 @@ +return { + { + "tpope/vim-sleuth", + } +} diff --git a/lua/plugins/splitjoin.lua b/lua/plugins/splitjoin.lua new file mode 100644 index 0000000..72a6bc4 --- /dev/null +++ b/lua/plugins/splitjoin.lua @@ -0,0 +1,16 @@ +return { + { + 'echasnovski/mini.splitjoin', + version = false, + keys = { + { "gS", function() require("mini.splitjoin").toggle() end, desc = "Toggle splitjoin" }, + }, + opts = { + mappings = { + toggle = '', + split = '', + join = '', + }, + }, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..124ab11 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,56 @@ +return { + { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "BurntSushi/ripgrep", + }, + keys = { + { "f", "Telescope find_files", desc = "Open file picker", }, + { "/", "Telescope live_grep", desc = "Global search", }, + { "b", "Telescope buffers", desc = "Open buffer picker", }, + { "j", "Telescope jumplist", desc = "Open jumplist picker", }, + { "g", "", desc = "Git", }, + { "gf", "Telescope git_files", desc = "Open git file picker", }, + { "gc", "Telescope git_commits", desc = "Browse git commits", }, + { "gd", "Telescope git_status", desc = "View git diff", }, + }, + cmd = "Telescope", + opts = { + defaults = { + layout_config = { + horizontal = { + preview_width = 0.6, + -- Show preview even for small windows + --preview_cutoff = 50, + }, + }, + }, + pickers = { + diagnostics = { + theme = "dropdown", + layout_config = { + width = 0.9, + }, + }, + }, + }, + config = function(_, opts) + local actions = require("telescope.actions") + opts.defaults.mappings = { i = { [""] = actions.close } } + + local telescope = require("telescope") + telescope.setup(opts) + end, + }, + { + "folke/todo-comments.nvim", + event = "VeryLazy", + dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" }, + opts = {}, + keys = { + { "t", "TodoTelescope", desc = "Open workspace TODOs listing", }, + }, + } +} + diff --git a/lua/plugins/theme.lua b/lua/plugins/theme.lua new file mode 100644 index 0000000..8cdf993 --- /dev/null +++ b/lua/plugins/theme.lua @@ -0,0 +1,20 @@ +return { + { + "catppuccin/nvim", + name = "catppuccin", + lazy = false, + priority = 1000, + opts = { + integrations = { + noice = true, + notify = true, + lsp_trouble = true, + which_key = true, + }, + }, + }, + { + -- auto-switch when GNOME theme changes + "vimpostor/vim-lumen", + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..60f7ff2 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,15 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + version = false, -- From LazyVim + build = ":TSUpdate", + opts = { + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = "all", + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + } +} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua new file mode 100644 index 0000000..3d00b3b --- /dev/null +++ b/lua/plugins/ui.lua @@ -0,0 +1,60 @@ +return { + { + "folke/noice.nvim", + event = "VeryLazy", + opts = { + lsp = { + -- 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, + }, + }, + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = true, -- add a border to hover docs and signature help + }, + }, + dependencies = { + { + "stevearc/dressing.nvim", + opts = { + input = { + mappings = { + i = { + [""] = "Close", + }, + }, + }, + select = { + backend = { "telescope" }, + telescope = require("telescope.themes").get_cursor(), + }, + }, + }, + { + "MunifTanjim/nui.nvim" + }, + --{ + -- "rcarriga/nvim-notify", + -- keys = { + -- { + -- "u", + -- function() + -- require("notify").dismiss() + -- end, + -- desc = "Dismiss all notifications" + -- }, + -- }, + -- opts = { + -- top_down = false, + -- }, + --}, + } + } +} + diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua new file mode 100644 index 0000000..0a63f1f --- /dev/null +++ b/lua/plugins/whichkey.lua @@ -0,0 +1,15 @@ +return { + { + "folke/which-key.nvim", + dependencies = { + "echasnovski/mini.icons", + }, + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = {}, + } +} + diff --git a/snippets/tex.snippets b/snippets/tex.snippets new file mode 100644 index 0000000..9cf7508 --- /dev/null +++ b/snippets/tex.snippets @@ -0,0 +1,6 @@ +# LaTeX Snippets + +snippet beg "begin/end snippet" + \begin{$1} + $0 + \end{$1}