From 44a03e92e063831ee9d47cc0f62584b708e652ee Mon Sep 17 00:00:00 2001 From: TheOnePath Date: Wed, 2 Oct 2024 17:27:37 +0100 Subject: [PATCH] Updated neovim config --- after/plugin/LSP.lua | 186 ------------ after/plugin/cmp_luasnip.lua | 19 -- after/plugin/completion.lua | 113 ------- after/plugin/luasnips.lua | 19 -- after/plugin/telescope.lua | 30 -- after/plugin/trouble.lua | 7 - init.lua | 48 +-- lua/core/init.lua | 17 ++ lua/core/keybindings.lua | 23 ++ lua/core/options.lua | 46 +++ lua/core/utils/icons.lua | 6 + lua/core/utils/lazy.lua | 29 ++ lua/plugin/init.lua | 15 - lua/plugin/lazy.lua | 283 ------------------ lua/plugins/configs/UI/bufferline.lua | 5 + lua/plugins/configs/UI/lualine.lua | 63 ++++ lua/plugins/configs/UI/neo-tree.lua | 29 ++ lua/plugins/configs/UI/noice.lua | 28 ++ lua/plugins/configs/UI/whichkey.lua | 46 +++ lua/plugins/configs/UI/zen.lua | 25 ++ lua/plugins/configs/completion/cmp.lua | 140 +++++++++ lua/plugins/configs/lsp/config.lua | 102 +++++++ lua/plugins/configs/lsp/native.lua | 6 + lua/plugins/configs/lsp/neodev.lua | 0 lua/plugins/configs/treesitter/init.lua | 115 +++++++ .../configs/treesitter/rainbow-delims.lua | 20 ++ lua/plugins/init.lua | 42 +++ lua/plugins/lazy.lua.bak | 60 ++++ lua/plugins/specs/completion.lua | 45 +++ lua/plugins/specs/core.lua | 8 + lua/plugins/specs/debug.lua | 31 ++ lua/plugins/specs/editor.lua | 63 ++++ lua/plugins/specs/lsp.lua | 120 ++++++++ lua/plugins/specs/telescope.lua | 89 ++++++ lua/plugins/specs/ui.lua | 124 ++++++++ lua/plugins/specs/vimwiki.lua | 53 ++++ 36 files changed, 1336 insertions(+), 719 deletions(-) delete mode 100644 after/plugin/LSP.lua delete mode 100644 after/plugin/cmp_luasnip.lua delete mode 100644 after/plugin/completion.lua delete mode 100644 after/plugin/luasnips.lua delete mode 100644 after/plugin/telescope.lua delete mode 100644 after/plugin/trouble.lua create mode 100644 lua/core/init.lua create mode 100644 lua/core/keybindings.lua create mode 100644 lua/core/options.lua create mode 100644 lua/core/utils/icons.lua create mode 100644 lua/core/utils/lazy.lua delete mode 100644 lua/plugin/init.lua delete mode 100644 lua/plugin/lazy.lua create mode 100644 lua/plugins/configs/UI/bufferline.lua create mode 100644 lua/plugins/configs/UI/lualine.lua create mode 100644 lua/plugins/configs/UI/neo-tree.lua create mode 100644 lua/plugins/configs/UI/noice.lua create mode 100644 lua/plugins/configs/UI/whichkey.lua create mode 100644 lua/plugins/configs/UI/zen.lua create mode 100644 lua/plugins/configs/completion/cmp.lua create mode 100644 lua/plugins/configs/lsp/config.lua create mode 100644 lua/plugins/configs/lsp/native.lua create mode 100644 lua/plugins/configs/lsp/neodev.lua create mode 100644 lua/plugins/configs/treesitter/init.lua create mode 100644 lua/plugins/configs/treesitter/rainbow-delims.lua create mode 100644 lua/plugins/init.lua create mode 100644 lua/plugins/lazy.lua.bak create mode 100644 lua/plugins/specs/completion.lua create mode 100644 lua/plugins/specs/core.lua create mode 100644 lua/plugins/specs/debug.lua create mode 100644 lua/plugins/specs/editor.lua create mode 100644 lua/plugins/specs/lsp.lua create mode 100644 lua/plugins/specs/telescope.lua create mode 100644 lua/plugins/specs/ui.lua create mode 100644 lua/plugins/specs/vimwiki.lua diff --git a/after/plugin/LSP.lua b/after/plugin/LSP.lua deleted file mode 100644 index 9970258..0000000 --- a/after/plugin/LSP.lua +++ /dev/null @@ -1,186 +0,0 @@ -local required = { 'mason', 'mason-lspconfig', 'lspconfig', 'cmp_nvim_lsp', 'fidget', 'neodev', 'mason-null-ls', - 'mason-nvim-dap', 'dap', 'dapui' } -local modules = {} - -for _, module in pairs(required) do - local ok, result = pcall(require, module) - if not ok then - print(module .. " is not install.") - return - end - - modules[module] = result -end - - -local capabilities = modules['cmp_nvim_lsp'].default_capabilities() - -modules['neodev'].setup() -modules["mason"].setup() -modules["mason-lspconfig"].setup { - ensure_installed = {"lua_ls"} -} - -modules["mason-lspconfig"].setup_handlers { - - function (server_name) - modules["lspconfig"][server_name].setup { - capabilities = capabilities - } - end, - ["omnisharp"] = function () - modules["lspconfig"]["omnisharp"].setup { - capabilities = capabilities, - on_attach = function (_,_) - local gr = vim.api.nvim_create_augroup("CS-OnAttach",{}) - vim.api.nvim_create_autocmd({"BufWritePre"}, { - group = gr, - pattern = {"*.cs"}, - desc = "(C#) Format before write", - callback = function () - vim.lsp.buf.format() - end - } - ) - end - } - end -} - -modules['mason-null-ls'].setup({ - ensure_installed = {}, - automatic_installation = false, - automatic_setup = true, -}) - - -modules['fidget'].setup{ - text = { - spinner = "dots" - } -} - --- Built in diagnostic settings are also configured here - -vim.diagnostic.config({ - virtual_text = true, - signs = true, - underline = true, - update_in_insert = true, - severity_sort = false, -}) - -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 = hl}) -end - -local auGroupDiagHover = vim.api.nvim_create_augroup("Diagnostic_hover",{clear = true}) -vim.api.nvim_create_autocmd("CursorHold",{ - pattern = {"*"}, - callback = function () - vim.diagnostic.open_float(nil, {focus=false, scope="cursor"}) - end, - group = auGroupDiagHover -}) - --- ## DAP ## warning: here be dragons -modules['mason-nvim-dap'].setup({ - automatic_setup = true, -}) - - -modules['dapui'].setup({ - icons = { - expanded = "", - collapsed = "", - current_frame = "", - }, - expand_lines = vim.fn.has("nvim-0.7") == 1, - layouts = { - { - elements = { - -- Elements can be strings or table with id and size keys. - { id = "scopes", size = 0.25 }, - "breakpoints", - "stacks", - "watches", - }, - size = 40, -- 40 columns - position = "left", - }, - { - elements = { - "repl", - "console", - }, - size = 0.25, -- 25% of total lines - position = "bottom", - }, - }, - controls = { - -- Requires Neovim nightly (or 0.8 when released) - enabled = true, - -- Display controls in this element - element = "repl", - icons = { - pause = "", - play = "", - step_into = "", - step_over = "", - step_out = "", - step_back = "", - run_last = "", - terminate = "", - }, - }, - floating = { - max_height = nil, -- These can be integers or a float between 0 and 1. - max_width = nil, -- Floats will be treated as percentage of your screen. - border = "single", -- Border style. Can be "single", "double" or "rounded" - mappings = { - close = { "q", "" }, - }, - }, - windows = { indent = 1 }, - render = { - max_type_length = nil, -- Can be integer or nil. - max_value_lines = 100, -- Can be integer or nil. - } -}) - -modules['dap'].listeners.after.event_initialized["dapui_config"] = function() - modules['dapui'].open() -end -modules['dap'].listeners.before.event_terminated["dapui_config"] = function() - modules['dapui'].close() -end -modules['dap'].listeners.before.event_exited["dapui_config"] = function() - modules['dapui'].close() -end - --- Also configure lspsaga here. --- Separate require check since we don't NEED lspsaga -local ok,lspsaga = pcall(require,"lspsaga") -if not ok then - return -end - --- Wrapping since some distros still don't ship nvim 0.8 -if vim.fn.exists('+winbar') ~= 0 then - lspsaga.setup({ - symbol_in_winbar = { - in_custom = false, - enable = true, - seperator = '>', - show_file = true, - click_support = false - }, - diagnostic_header = { " ", " ", " ", "ﴞ " }, - }) -else - lspsaga.setup({ - diagnostic_header = { " ", " ", " ", "ﴞ " }, - }) -end diff --git a/after/plugin/cmp_luasnip.lua b/after/plugin/cmp_luasnip.lua deleted file mode 100644 index 0ddc5b6..0000000 --- a/after/plugin/cmp_luasnip.lua +++ /dev/null @@ -1,19 +0,0 @@ -require("cmp").register_source("luasnip", require("cmp_luasnip").new()) - -local cmp_luasnip = vim.api.nvim_create_augroup("cmp_luasnip", {}) - -vim.api.nvim_create_autocmd("User", { - pattern = "LuasnipCleanup", - callback = function () - require("cmp_luasnip").clear_cache() - end, - group = cmp_luasnip -}) - -vim.api.nvim_create_autocmd("User", { - pattern = "LuasnipSnippetsAdded", - callback = function () - require("cmp_luasnip").refresh() - end, - group = cmp_luasnip -}) diff --git a/after/plugin/completion.lua b/after/plugin/completion.lua deleted file mode 100644 index 6859e88..0000000 --- a/after/plugin/completion.lua +++ /dev/null @@ -1,113 +0,0 @@ --- Configure Completion -vim.opt.completeopt = {"menu","menuone","noselect"} -vim.opt.shortmess:append "c" - -local ok, lspkind = pcall(require, "lspkind") -if not ok then - print("lspkind is not installed.") - return -end - -lspkind.init() - -local luasnip = require("luasnip") -local status, cmp = pcall(require, "cmp") -if not status then - print("nvim-cmp is not installed.") - return -end - -if cmp == nil then - return -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 - -cmp.setup { - enabled = function () - -- disable complete in comments - local context = require'cmp.config.context' - -- keep command mode completion enabled when cursor is in a comment - if vim.api.nvim_get_mode().mode == 'c' then - return true - else - return not context.in_treesitter_capture("comment") - and not context.in_syntax_group("Comment") - end - end, - mapping = { - [""] = 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" }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete { - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }, - [''] = cmp.mapping.abort(), - [""] = cmp.mapping( - cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - - }, - sources = { - {name = "nvim_lua"}, - {name = "nvim_lsp"}, - {name = "path"}, - {name = "luasnip"}, - { - name = "buffer", - option = { - keyword_length = 5, - }, - }, - }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, ---- experimental = { ---- native_menu = false, ---- ghost_text = true, ---- }, - formatting = { - format = lspkind.cmp_format { - mode = 'symbol_text', - menu = { - buffer = "[BUF]", - nvim_lsp = "[LSP]", - nvim_lua = "[API]", - path = "[PTH]", - luasnip = "[SNP]" - } - } - } -} - - - diff --git a/after/plugin/luasnips.lua b/after/plugin/luasnips.lua deleted file mode 100644 index 7ca6660..0000000 --- a/after/plugin/luasnips.lua +++ /dev/null @@ -1,19 +0,0 @@ -local ok, ls = pcall(require, 'luasnip') -if not ok then - print("NO SNIPS?") - return -end - --- local types = require "luasnip.util.types" -ls.config.set_config{ - - -- remember the last snippet - history = true, - - -- make dynamic snippets update with typing - updateevents = "TextChanged,TextChangedI", - - --Autosnippets: - enable_autosnippets = true, -} -require("luasnip/loaders/from_vscode").lazy_load() diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua deleted file mode 100644 index 0f9ec00..0000000 --- a/after/plugin/telescope.lua +++ /dev/null @@ -1,30 +0,0 @@ -local ok, telescope = pcall(require, 'telescope') -if not ok then - print("Telescope is not installed.") - return -end - -telescope.setup { - -- configuration of Telescope go here - defaults = { - prompt_prefix = "🔎 ", - layout_config = { - height = 0.90, - prompt_position = "top", - preview_height = 15, - }, - sorting_strategy = "ascending", - dynamic_preview_title = true, - }, - pickers = { }, - extensions = { - file_browser = { - grouped = true, - hijack_netrw = true, - dir_icon = "📁", - hidden = true, - } - } -} - -telescope.load_extension "file_browser" diff --git a/after/plugin/trouble.lua b/after/plugin/trouble.lua deleted file mode 100644 index 0b37d47..0000000 --- a/after/plugin/trouble.lua +++ /dev/null @@ -1,7 +0,0 @@ -local ok, trouble = pcall(require, 'trouble') -if not ok then - print("Looks like there was a little trouble...cus it's missing.") - return -end - -trouble.setup {} diff --git a/init.lua b/init.lua index 74045cb..e0c631b 100644 --- a/init.lua +++ b/init.lua @@ -1,47 +1 @@ -require('plugin') - --- Instantiate the gruvbox theme via native vimscript --- Note: this always comes before anything, or the theme breaks -vim.cmd([[ - set termguicolors - let g:gruvbox_italic=1 - set cursorline - set cursorcolumn - set number - set spell - set textwidth=120 sw=4 ts=4 et colorcolumn=120 - highlight ColorColumn ctermbg=0 - set splitbelow splitright - autocmd BufRead,BufNewFile *.bottle set filetype=bottle - AirlineTheme catppuccin -]]) - --- implement the DiffOrig command (see :h :DiffOrig for more info) -vim.cmd([[ - command DiffOrig vert new | set bt=nofile | set bufhidden | set pvw - \ | r # | 0d_ | diffthis | wincmd p | diffthis - command DiffOff diffoff | pc -]]) - --- Custom keybindings using the util `map` function -local map = require("utils").map -local opts = { silent=true } - -vim.g.mapleader = 'e' -- leader for Edit Mode functions ---- Mappings for Edit Mode --- -map("v", "h", ":s//") -- visual selection replace with last buffer item -map("n", "g", "Telescope live_grep", opts) -- Telescope live grep search -map("n", "o", "Telescope file_browser", opts) -- Open Telescope to grab new file - -vim.g.mapleader = 'f' -- leader for File Mode functions ---- Mappings for File Mode --- ---map("n", "o", "Telescope file_browser", opts) -- Telescope file browser -map("ni", "T", "tabnew | Telescope file_browser", opts) -- Open a new tab buffer -map("ni", "v", "v | Telescope file_browserA", opts) -- Open a new verticle split -map("ni", "s", "s | Telescope file_browserA", opts) -- Open a new horizontal split - -vim.g.mapleader = 't' -- leader for Terminal Mode functions ---- Mappings for Terminal Mode --- -map("n", "vr", ":vert res 80") -- change verticle size of focused window to x (Default: x = 80) -map("n", "hr", ":horizontal res ") -- change horizontal size of focused window to x (No default) - +require'core'.setup() diff --git a/lua/core/init.lua b/lua/core/init.lua new file mode 100644 index 0000000..c1ca694 --- /dev/null +++ b/lua/core/init.lua @@ -0,0 +1,17 @@ +local M = {} + +M.setup = function () + require'core.options' + require'core.keybindings' + require'plugins' + + -- implement the DiffOrig command (see :h :DiffOrig for more info) + vim.cmd([[ + command DiffOrig vert new | set bt=nofile | set bufhidden | set pvw + \ | r # | 0d_ | diffthis | wincmd p | diffthis + command DiffOff diffoff | pc + ]]) + +end + +return M diff --git a/lua/core/keybindings.lua b/lua/core/keybindings.lua new file mode 100644 index 0000000..dd8b8e7 --- /dev/null +++ b/lua/core/keybindings.lua @@ -0,0 +1,23 @@ +-- Custom keybindings using the util `map` function +local map = require'utils'.map +local opts = { silent=true } + +vim.g.mapleader = 'e' -- leader for Edit Mode functions +--- Mappings for Edit Mode --- +map("v", "h", ":s//") -- visual selection replace with last buffer item +map("n", "g", "Telescope live_grep", opts) -- Telescope live grep search +map("n", "o", "Telescope file_browser", opts) -- Open Telescope to grab new file + +vim.g.mapleader = 'f' -- leader for File Mode functions +--- Mappings for File Mode --- +--map("n", "o", "Telescope file_browser", opts) -- Telescope file browser +map("ni", "T", "tabnew | Telescope file_browser", opts) -- Open a new tab buffer +map("ni", "v", "v | Telescope file_browserA", opts) -- Open a new verticle split +map("ni", "s", "s | Telescope file_browserA", opts) -- Open a new horizontal split +map("n", "do", "DiffOrig", opts) +map("n", "dc", "DiffOff", opts) + +vim.g.mapleader = 't' -- leader for Terminal Mode functions +--- Mappings for Terminal Mode --- +map("n", "vr", ":vert res 80") -- change verticle size of focused window to x (Default: x = 80) +map("n", "hr", ":horizontal res ") -- change horizontal size of focused window to x (No default) diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..f53be73 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,46 @@ +local opt = vim.opt + +vim.g.mapleader = '\\' +vim.g.maplocalleader = ',' + +-- enable line numbering +opt.number = true + +-- enable splitting to right and below +opt.splitright = true +opt.splitbelow = true + +-- enable 24-bit colour terminal +opt.termguicolors = true + +-- set terminal title +opt.title = true + +-- enable spelling for EN-GB +opt.spell = true +opt.spelllang = 'en_gb' + +-- ignore compiled files in completion +opt.wildignore = { + '*pycache*', + '*.o', + '*~', + '*.pyc', +} + +-- enable cursor line and column +opt.cursorline = true +opt.cursorcolumn = true + +-- line control +opt.expandtab = true +opt.textwidth = 80 +opt.shiftwidth = 2 +opt.tabstop = 2 +opt.colorcolumn = '+1' + +-- extra options set through vim.cmd +vim.cmd([[ + let g:gruvbox_italic=1 + highlight ColorColumn ctermbg=lightgrey +]]) diff --git a/lua/core/utils/icons.lua b/lua/core/utils/icons.lua new file mode 100644 index 0000000..794034a --- /dev/null +++ b/lua/core/utils/icons.lua @@ -0,0 +1,6 @@ +return { + Error = '', + Warn = '', + Hint = '', + Info = '', +} diff --git a/lua/core/utils/lazy.lua b/lua/core/utils/lazy.lua new file mode 100644 index 0000000..e94331e --- /dev/null +++ b/lua/core/utils/lazy.lua @@ -0,0 +1,29 @@ +return function(plugin) + vim.api.nvim_create_autocmd({ 'BufRead', 'BufWinEnter', 'BufNewFile', 'WinEnter' }, { + callback = function() + if vim.fn.expand('%') ~= '' then + -- dont defer for treesitter as it will show slow highlighting + -- This deferring only happens only when we do "nvim filename" + if plugin ~= 'nvim-treesitter' then + vim.schedule(function() + require('lazy').load { plugins = plugin } + + if + plugin == 'nvim-lspconfig' + or plugin == 'null-ls.nvim' + or plugin == 'vim-matchup' + then + vim.cmd('silent! do FileType') + + if plugin == 'null-ls.nvim' then + require('null-ls.state').register_conditional_sources() + end + end + end) + else + require'lazy'.load { plugins = plugin } + end + end + end, + }) +end diff --git a/lua/plugin/init.lua b/lua/plugin/init.lua deleted file mode 100644 index 995cf64..0000000 --- a/lua/plugin/init.lua +++ /dev/null @@ -1,15 +0,0 @@ ---- bootstrapping Lazy.nvim -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( require'plugin.lazy' ) diff --git a/lua/plugin/lazy.lua b/lua/plugin/lazy.lua deleted file mode 100644 index 3ecc83f..0000000 --- a/lua/plugin/lazy.lua +++ /dev/null @@ -1,283 +0,0 @@ -return { - -- lazy itself - { - 'folke/lazy.nvim', - version = '*' - }, - - { - 'catppuccin/nvim', - name = "catppuccin", - lazy = false, - priority = 1000, - config = function() - require'catppuccin'.setup({ - color_overrides = { - macchiato = { - text = "#feffe9", --"#b7d69b", - subtext1 = "#a8c68f", - subtext0 = "#98b381", - overlay2 = "#879f72", - overlay1 = "#758a63", - overlay0 = "#647554", - surface2 = "#526146", - surface1 = "#414d37", - surface0 = "#303828", - base = "#262e1e", - mantle = "#1d2417", - crust = "#151a10", - } - } - }) - vim.cmd([[colorscheme catppuccin-macchiato]]) - end - }, - - { - 'morhetz/gruvbox', -- Neovim editor theme (gruvbox MVP) - lazy = false, - priority = 1000, - config = function() - -- vim.cmd([[colorscheme gruvbox]]) - end - }, - - -- treesitter - { - 'nvim-treesitter/nvim-treesitter', - version = false, - event = { "BufReadPost", "BufWritePost", "BufNewFile", "VeryLazy" }, - build = ":TSUpdate", - init = function(plugin) - -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early - -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which - -- no longer trigger the **nvim-treeitter** module to be loaded in time. - -- Luckily, the only thins that those plugins need are the custom queries, which we make available - -- during startup. - require("lazy.core.loader").add_to_rtp(plugin) - require("nvim-treesitter.query_predicates") - end, - dependencies = { - { - "nvim-treesitter/nvim-treesitter-textobjects", - config = function() - -- When in diff mode, we want to use the default - -- vim text objects c & C instead of the treesitter ones. - local move = require("nvim-treesitter.textobjects.move") ---@type table - local configs = require("nvim-treesitter.configs") - for name, fn in pairs(move) do - if name:find("goto") == 1 then - move[name] = function(q, ...) - if vim.wo.diff then - local config = configs.get_module("textobjects.move")[name] ---@type table - for key, query in pairs(config or {}) do - if q == query and key:find("[%]%[][cC]") then - vim.cmd("normal! " .. key) - return - end - end - end - return fn(q, ...) - end - end - end - end, - }, - }, - cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, - }, - - -- Telescope - { - { - 'nvim-telescope/telescope.nvim', - event = "VeryLazy", - dependencies = { - "nvim-telescope/telescope-file-browser.nvim", - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - 'nvim-lua/plenary.nvim', - "nvim-tree/nvim-web-devicons", - }, - }, - }, - - -- cmdline tools and lsp servers - -- - { - 'neovim/nvim-lspconfig', -- Configurations for Nvim LSP - dependencies = { - { "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } }, - { "folke/neodev.nvim", opts = {} }, - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - }, - config = function() - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - - require('mason').setup() - local mason_lspconfig = require 'mason-lspconfig' - mason_lspconfig.setup { - ensure_installed = { "pyright" } - } - - require("lspconfig").pyright.setup { - capabilities = capabilities, - } - end - }, - - -- mason.nvim - { - "williamboman/mason.nvim", - cmd = "Mason", - keys = { { "cm", "Mason", desc = "Mason" } }, - build = ":MasonUpdate", - opts = { - ensure_installed = { - "stylua", - "shfmt", - -- "flake8", - }, - }, - ---@param opts MasonSettings | {ensure_installed: string[]} - config = function(_, opts) - require("mason").setup(opts) - local mr = require("mason-registry") - mr:on("package:install:success", function() - vim.defer_fn(function() - -- trigger FileType event to possibly load this newly installed LSP server - require("lazy.core.handler.event").trigger({ - event = "FileType", - buf = vim.api.nvim_get_current_buf(), - }) - end, 100) - end) - local function ensure_installed() - for _, tool in ipairs(opts.ensure_installed) do - local p = mr.get_package(tool) - if not p:is_installed() then - p:install() - end - end - end - if mr.refresh then - mr.refresh(ensure_installed) - else - ensure_installed() - end - end, - }, - - { - 'jay-babu/mason-null-ls.nvim', - lazy = true, - dependencies = { - 'jose-elias-alvarez/null-ls.nvim', - 'williamboman/mason.nvim' - } - }, - - { - 'jay-babu/mason-nvim-dap.nvim', - lazy = true, - dependencies = { - 'williamboman/mason.nvim', - 'mfussenegger/nvim-dap' - } - }, - { - 'rcarriga/nvim-dap-ui', - lazy = true, - dependencies = { - "mfussenegger/nvim-dap" - } - }, - -- - - -- auto pairs - { - "echasnovski/mini.pairs", - event = "VeryLazy", - opts = {}, - keys = {{ - "up", - function() - local Util = require("lazy.core.util") - vim.g.minipairs_disable = not vim.g.minipairs_disable - if vim.g.minipairs_disable then - Util.warn("Disabled auto pairs", { title = "Option" }) - else - Util.info("Enabled auto pairs", { title = "Option" }) - end - end, - desc = "Toggle auto pairs", - }}, - }, - - -- auto completion - { - 'hrsh7th/nvim-cmp', - version = false, -- last release is way too old - event = "InsertEnter", - dependencies = { - 'hrsh7th/cmp-buffer', -- completion source - 'hrsh7th/cmp-path', -- completion source - 'hrsh7th/cmp-nvim-lua', -- completion source - 'hrsh7th/cmp-nvim-lsp', -- completion source - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', - 'onsails/lspkind.nvim', - }, - }, - - -- misc - { - 'vim-airline/vim-airline', - }, - - { - 'j-hui/fidget.nvim', - tag = "legacy" - }, - - { - "folke/trouble.nvim", - lazy = true, - dependencies = "nvim-tree/nvim-web-devicons", - }, - - { - "L3MON4D3/LuaSnip", - dependencies = { "rafamadriz/friendly-snippets" }, - event = "VeryLazy", - }, - - -- Live Preview of MD - { - "iamcco/markdown-preview.nvim", - config = function() vim.fn["mkdp#util#install"]() end, - }, - - -- Need to short this out properly! - -- learn this - 'tpope/vim-surround', - -- differentiate brackets - 'luochen1990/rainbow', - -- File tree - 'preservim/nerdtree', - -- Distraction free writing - 'junegunn/goyo.vim', - -- The Best Thing EVER - 'vimwiki/vimwiki', - -- better comments - 'scrooloose/nerdcommenter', - -- Show colours - 'ap/vim-css-color', - -- Add snippets - 'honza/vim-snippets', - -- highlight matching html tags --- 'valloric/matchtagalways', - -- Syntax highlighting extension - 'sheerun/vim-polyglot', -} diff --git a/lua/plugins/configs/UI/bufferline.lua b/lua/plugins/configs/UI/bufferline.lua new file mode 100644 index 0000000..ceef78f --- /dev/null +++ b/lua/plugins/configs/UI/bufferline.lua @@ -0,0 +1,5 @@ +return { + options = { + diagnostics = 'nvim-lsp', + }, +} diff --git a/lua/plugins/configs/UI/lualine.lua b/lua/plugins/configs/UI/lualine.lua new file mode 100644 index 0000000..a554bb2 --- /dev/null +++ b/lua/plugins/configs/UI/lualine.lua @@ -0,0 +1,63 @@ +return { + options = { + icons_enabled = true, + theme = 'gruvbox', + component_separators = { + left = '|', + right = '|', + }, + section_separators = { + left = '', + right = '', + }, + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = true, + }, + sections = { + lualine_a = { + 'mode', + 'spell_status', + }, + lualine_b = { + 'branch', + 'diff', + 'diagnostics', + }, + lualine_c = { + { + 'filename', + path = 1, + }, + { + 'filetype', + icon_only = true, + }, + }, + lualine_x = { + 'encoding', + 'fileformat', + 'filetype', + { + require('lazy.status').updates, + cond = require('lazy.status').has_updates, + }, + { + require('noice').api.status.mode.get, + cond = require('noice').api.status.mode.has, + }, + }, + lualine_y = { + 'progress', + 'searchcount', + }, + lualine_z = { + 'location', + }, + }, + tabline = {}, + extensions = { + 'neo-tree', + 'quickfix', + }, +} diff --git a/lua/plugins/configs/UI/neo-tree.lua b/lua/plugins/configs/UI/neo-tree.lua new file mode 100644 index 0000000..1659f68 --- /dev/null +++ b/lua/plugins/configs/UI/neo-tree.lua @@ -0,0 +1,29 @@ +return { + enable_git_status = true, + enable_diagnostics = true, + sort_case_insensitive = true, + + filesystem = { + filtered_items = { + visible = false, + hide_dotfiles = true, + hide_gitignored = true, + hide_hidden = true, + }, + follow_current_file = { + enabled = true, + }, + hijack_netrw_behaviour = 'open_default', + use_libuv_file_watcher = true, + }, + + window = { + position = 'left', + }, + + buffers = { + follow_current_file = { + enabled = true, + }, + }, +} diff --git a/lua/plugins/configs/UI/noice.lua b/lua/plugins/configs/UI/noice.lua new file mode 100644 index 0000000..ccacf91 --- /dev/null +++ b/lua/plugins/configs/UI/noice.lua @@ -0,0 +1,28 @@ +return { + lsp = { + 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, + command_palette = true, + long_message_to_split = true, + inc_rename = false, + lsp_doc_border = false, + }, + hover = { + enabled = true, + }, + signature = { + enabled = true, + auto_open = { + enabled = true, + trigger = true, -- Automatically show signature help when typing a trigger character from the LSP + luasnip = true, -- Will open signature help when jumping to Luasnip insert nodes + throttle = 50, -- Debounce lsp signature help request by 50ms + }, + }, +} diff --git a/lua/plugins/configs/UI/whichkey.lua b/lua/plugins/configs/UI/whichkey.lua new file mode 100644 index 0000000..c125bf2 --- /dev/null +++ b/lua/plugins/configs/UI/whichkey.lua @@ -0,0 +1,46 @@ +M = {} + +M.config = { + plugins = { + marks = true, + registers = true, + spelling = { + enabled = true, + suggestions = 10, + }, + + presets = { + operators = true, + motions = true, + text_objects = true, + windows = true, + nav = true, + z = true, + g = true, + }, + }, + icons = { + breadcrumb = '󰇘', + separator = '󰇼', + group = '󰋃', + }, + + win = { + border = 'single', + }, + -- ignore_missing = true, + disable = { + filetypes = { 'TelescopePrompt' }, + }, +} + +M.default_bindings = { + { 'c', group = 'NerdComment' }, + { 'f', group = 'File' }, + { 'l', group = 'LSP' }, + { 't', group = 'telescope' }, + { 'ts', group = 'tresitter' }, + { 'w', group = 'vimwiki' }, +} + +return M diff --git a/lua/plugins/configs/UI/zen.lua b/lua/plugins/configs/UI/zen.lua new file mode 100644 index 0000000..c01f523 --- /dev/null +++ b/lua/plugins/configs/UI/zen.lua @@ -0,0 +1,25 @@ +return { + window = { + backdrop = 0.95, + width = 0.80, + height = 0.50, + options = { + signcolumn = 'no', + number = false, + relativenumber = false, + cursorline = true, + cursorcolumn = false, + foldcolumn = '0', + list = false, + }, + }, + plugins = { + options = { + enabled = true, + ruler = false, + showcmd = false, + }, + twilight = { enabled = true }, + gitsigns = { enabled = true }, + }, +} diff --git a/lua/plugins/configs/completion/cmp.lua b/lua/plugins/configs/completion/cmp.lua new file mode 100644 index 0000000..38a3f4d --- /dev/null +++ b/lua/plugins/configs/completion/cmp.lua @@ -0,0 +1,140 @@ +local M = {} + +local luasnip = require('luasnip') +local cmp = require('cmp') +local compare = require('cmp.config.compare') +local lspkind = require('lspkind') + +-- Global config table +M.cmp = { + preselect = cmp.PreselectMode.None, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + completion = { + scrollbar = false, + }, + }, + mapping = { + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping { + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + else + fallback() + end + end, + s = cmp.mapping.confirm { select = false }, + c = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = false, + }, + }, + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + if cmp.visible_docs() then + cmp.close_docs() + else + cmp.open_docs() + end + end + fallback() + end), + [''] = cmp.mapping.abort(), + }, + sources = cmp.config.sources { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'lazydev', group_index = 0 }, + { name = 'path' }, + { name = 'buffer', keyword_length = 5 }, + { name = 'conjure' }, + { name = 'emoji', priority = -20 }, + }, + formatting = { + format = lspkind.cmp_format { + mode = 'symbol_text', + menu = { + buffer = '[BUF]', + nvim_lsp = '[LSP]', + path = '[PTH]', + luasnip = '[SNP]', + emoji = '[EMJ]', + }, + maxwidth = 50, + ellipsis_char = '', + }, + }, + experimental = { + ghost_text = true, + }, + sorting = { + priority_weight = 0.8, + comparators = { + compare.score, + compare.exact, + compare.offset, + compare.sort_text, + compare.scopes, + compare.recently_used, + compare.order, + compare.kind, + compare.length, + }, + }, + performance = { + fetching_timeout = 30, + }, +} + +--- Configure completion for commandline +M.cmd = function() + -- completion for searches + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' }, + }, + }) + + cmp.setup.cmdline({ '@' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'cmdline' }, + }, + }) + + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + }, { + { name = 'cmdline' }, + }), + }) +end + +return M diff --git a/lua/plugins/configs/lsp/config.lua b/lua/plugins/configs/lsp/config.lua new file mode 100644 index 0000000..a0176a2 --- /dev/null +++ b/lua/plugins/configs/lsp/config.lua @@ -0,0 +1,102 @@ +local M = {} + +M.on_attach = function() + local auGroupOnAttach = vim.api.nvim_create_augroup('on_attach', { clear = true }) + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client == nil then return end + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(true, nil, bufnr) + end + + if client.server_capabilities.documentFormattingProvider then + vim.keymap.set({ 'n' }, 'lf', function() + vim.lsp.buf.format() + end, { desc = 'Format buffer' }) + end + end, + group = auGroupOnAttach, + }) +end + +M.setup = function(opts) + local servers_to_not_setup = opts.servers_to_not_setup + + local capabilities = vim.lsp.protocol.make_client_capabilities() + + capabilities.textDocument = { + completion = { + completionItem = { + documentationFormat = { 'markdown', 'plaintext' }, + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { + 'documentation', + 'detail', + 'additionalTextEdits', + }, + }, + }, + }, + foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + }, + } + + local checkIfExists = function(val, arr) + local y = false + for i in ipairs(arr) do + if arr[i] == val and y ~= true then y = true end + end + return y + end + + local servers = opts.servers + + local function setup(server) + if not checkIfExists(server, servers_to_not_setup) then + local server_opts = vim.tbl_deep_extend('force', { + capabilities = vim.deepcopy(capabilities), + }, servers[server] or {}) + + if opts.setup[server] then + if opts.setup[server](server, server_opts) then return end + elseif opts.setup['*'] then + if opts.setup['*'](server, server_opts) then return end + end + require('lspconfig')[server].setup(server_opts) + M.on_attach() + end + end + -- get all the servers that are available through mason-lspconfig + local have_mason, mlsp = pcall(require, 'mason-lspconfig') + local all_mslp_servers = {} + if have_mason then + all_mslp_servers = + vim.tbl_keys(require('mason-lspconfig.mappings.server').lspconfig_to_package) + end + + local ensure_installed = {} ---@type string[] + + for server, server_opts in pairs(servers) do + server_opts = server_opts == true and {} or server_opts + if not vim.tbl_contains(all_mslp_servers, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end + end + + if have_mason then mlsp.setup { ensure_installed = ensure_installed, handlers = { setup } } end +end + +return M diff --git a/lua/plugins/configs/lsp/native.lua b/lua/plugins/configs/lsp/native.lua new file mode 100644 index 0000000..4e2e3e2 --- /dev/null +++ b/lua/plugins/configs/lsp/native.lua @@ -0,0 +1,6 @@ +local icons = require('core.utils.icons') + +for name, icon in pairs(icons) do + name = 'DiagnosticSign' .. name + vim.fn.sign_define(name, { text = icon, texthl = name, numhl = '' }) +end diff --git a/lua/plugins/configs/lsp/neodev.lua b/lua/plugins/configs/lsp/neodev.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/plugins/configs/treesitter/init.lua b/lua/plugins/configs/treesitter/init.lua new file mode 100644 index 0000000..720e3e2 --- /dev/null +++ b/lua/plugins/configs/treesitter/init.lua @@ -0,0 +1,115 @@ +return { + ensure_installed = { + 'bash', + 'c', + 'cpp', + 'css', + 'c_sharp', + 'diff', + 'git_config', + 'git_rebase', + 'gitcommit', + 'gitignore', + 'go', + 'gomod', + 'html', + 'ini', + 'javascript', + 'jsonnet', + 'latex', + 'lua', + 'luadoc', + 'luap', + 'make', + 'markdown', + 'markdown_inline', + 'python', + 'query', + 'regex', + 'rust', + 'scss', + 'toml', + 'vim', + 'vimdoc', + 'yuck', + 'yaml', + 'zig', + }, + auto_install = true, + + highlight = { + enable = true, + }, + + indent = { + enable = true, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + scope_incremental = '', + node_incremental = '', + node_decremental = '', + }, + }, + + textobjects = { + select = { + enable = true, + lookahead = true, + + keymaps = { + ['af'] = { query = '@function.outer', desc = 'Select outer part of function' }, + ['if'] = { query = '@function.inner', desc = 'Select inner part of function' }, + ['ac'] = { query = '@class.outer', desc = 'Select outer part of class' }, + ['ic'] = { query = '@class.inner', desc = 'Select inner part of class' }, + }, + }, + + move = { + enable = true, + set_jumps = true, + + goto_next_start = { + [']m'] = { query = '@function.outer', desc = 'Next Function start' }, + [']]'] = { query = '@class.outer', desc = 'Next class start' }, + [']o'] = { query = '@loop.*', desc = 'Next loop component' }, + [']z'] = { query = '@fold', query_group = 'folds', desc = 'Next Fold' }, + }, + goto_next_end = { + [']M'] = { query = '@function.outer', desc = 'Next Function end' }, + [']['] = { query = '@class.outer', desc = 'Next class end' }, + }, + goto_previous_start = { + ['[m'] = { query = '@function.outer', desc = 'Previous Function start' }, + ['[]'] = { query = '@class.outer', desc = 'Previous class start' }, + ['[o'] = { query = '@loop.*', desc = 'Previous loop component' }, + ['[z'] = { query = '@fold', query_group = 'folds', desc = 'Previous Fold' }, + }, + goto_previous_end = { + ['[M'] = { query = '@function.outer', desc = 'Previous Function end' }, + ['[['] = { query = '@class.outer', desc = 'Previous class end' }, + }, + + goto_next = { + [']d'] = { query = '@conditional.*', desc = 'Next Conditional' }, + }, + goto_previous = { + ['[d'] = { query = '@conditional.*', desc = 'previous Conditional' }, + }, + }, + + lsp_interop = { + enable = true, + border = 'none', + floating_preview_opts = {}, + + peek_definition_code = { + ['tsdf'] = { query = '@function.outer', desc = 'Peek function definition' }, + ['tsdF'] = { query = '@class.outer', desc = 'Peek class definition' }, + }, + }, + }, +} diff --git a/lua/plugins/configs/treesitter/rainbow-delims.lua b/lua/plugins/configs/treesitter/rainbow-delims.lua new file mode 100644 index 0000000..d28a217 --- /dev/null +++ b/lua/plugins/configs/treesitter/rainbow-delims.lua @@ -0,0 +1,20 @@ +local rainbow = require('rainbow-delimiters') +return { + strategy = { + [''] = rainbow.strategy['global'], + }, + query = { + [''] = 'rainbow-delimiters', + lua = 'rainbow-blocks', + latex = 'rainbow-blocks', + }, + highlight = { + 'RainbowDelimiterRed', + 'RainbowDelimiterYellow', + 'RainbowDelimiterBlue', + 'RainbowDelimiterOrange', + 'RainbowDelimiterGreen', + 'RainbowDelimiterViolet', + 'RainbowDelimiterCyan', + }, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..12903fa --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,42 @@ +--- bootstrapping Lazy.nvim +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( { import = 'plugins.specs' }, { + defaults = { + lazy = true, + version = false, + }, + + install = { + missing = true, + colorscheme = { 'catppuccino' }, + }, + + checker = { + enabled = true, + }, + + performance = { + rtp = { + disabled_plugins = { + 'tutor', + 'gzip', + 'tarPlugin', + 'zipPlugin', + 'netrwPlugin' + }, + }, + }, +}) diff --git a/lua/plugins/lazy.lua.bak b/lua/plugins/lazy.lua.bak new file mode 100644 index 0000000..1086753 --- /dev/null +++ b/lua/plugins/lazy.lua.bak @@ -0,0 +1,60 @@ +return { + -- lazy itself + { + 'folke/lazy.nvim', + version = '*' + }, + + + { + 'jay-babu/mason-null-ls.nvim', + lazy = true, + dependencies = { + 'jose-elias-alvarez/null-ls.nvim', + 'williamboman/mason.nvim' + } + }, + + + -- misc + + { + 'j-hui/fidget.nvim', + tag = "legacy" + }, + + { + "folke/trouble.nvim", + lazy = true, + dependencies = "nvim-tree/nvim-web-devicons", + }, + + -- Live Preview of MD + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + ft = { "markdown" }, + build = function() vim.fn["mkdp#util#install"]() end, + }, + -- Need to short this out properly! + -- learn this + 'tpope/vim-surround', + -- differentiate brackets + 'luochen1990/rainbow', + -- File tree + 'preservim/nerdtree', + -- Distraction free writing + 'junegunn/goyo.vim', + -- The Best Thing EVER + 'vimwiki/vimwiki', + -- better comments + 'scrooloose/nerdcommenter', + -- Show colours + 'ap/vim-css-color', + -- Add snippets + 'honza/vim-snippets', + -- highlight matching html tags +-- 'valloric/matchtagalways', + -- Syntax highlighting extension + 'sheerun/vim-polyglot', +} diff --git a/lua/plugins/specs/completion.lua b/lua/plugins/specs/completion.lua new file mode 100644 index 0000000..c0533d6 --- /dev/null +++ b/lua/plugins/specs/completion.lua @@ -0,0 +1,45 @@ +-- Completion config. +return { + { + 'L3MON4D3/LuaSnip', -- snippet engine + build = function() + if vim.fn.has('win32') == 0 then + return "echo -e 'NOTE: jsregexp is optional, failure here is ok' ; make install_jsregexp" + end + vim.fn.system({"make", "install_jsregexp"}) + return nil + end, + config = function() + local lua_snippets = vim.fn.stdpath('config') .. '/luasnip' + local vscode_snippets = vim.fn.stdpath('config') .. '/snippets' + require('luasnip.loaders.from_vscode').lazy_load() -- load friendly-snippets + require('luasnip.loaders.from_vscode').lazy_load { paths = { vscode_snippets } } + require('luasnip.loaders.from_lua').lazy_load { paths = { lua_snippets } } + end, + dependencies = { + 'rafamadriz/friendly-snippets', + }, + }, + { + 'hrsh7th/nvim-cmp', + opts = function() + return require('plugins.configs.completion.cmp') + end, + config = function(_, opts) + local cmp = require('cmp') + cmp.setup(opts.cmp) + opts.cmd() + end, + event = { 'InsertEnter', 'VeryLazy', 'CmdlineEnter' }, + dependencies = { + 'LuaSnip', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-emoji', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + 'onsails/lspkind.nvim', + 'saadparwaiz1/cmp_luasnip', + }, + }, +} diff --git a/lua/plugins/specs/core.lua b/lua/plugins/specs/core.lua new file mode 100644 index 0000000..a29fc5a --- /dev/null +++ b/lua/plugins/specs/core.lua @@ -0,0 +1,8 @@ +return { + + { 'munifTanjim/nui.nvim' }, + { 'nvim-lua/plenary.nvim' }, + { 'nvim-lua/popup.nvim' }, + { 'nvim-tree/nvim-web-devicons' }, + +} diff --git a/lua/plugins/specs/debug.lua b/lua/plugins/specs/debug.lua new file mode 100644 index 0000000..cab9c76 --- /dev/null +++ b/lua/plugins/specs/debug.lua @@ -0,0 +1,31 @@ +return { + { + 'mfussenegger/nvim-dap' + }, + + { -- nvim-dap-virtual-text + 'theHamsta/nvim-dap-virtual-text', + dependencies = { + 'mfussenegger/nvim-dap', + 'nvim-treesitter/nvim-treesitter', + }, + }, + { -- nvim-dap-ui + 'rcarriga/nvim-dap-ui', + dependencies = { + 'mfussenegger/nvim-dap', + 'theHamsta/nvim-dap-virtual-text', + 'nvim-neotest/nvim-nio', + }, + opts = {}, + keys = { + { + 'dt', + function() + require('dapui').toggle() + end, + desc = 'open dapui', + }, + }, + }, +} diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua new file mode 100644 index 0000000..0dd9411 --- /dev/null +++ b/lua/plugins/specs/editor.lua @@ -0,0 +1,63 @@ +return { + + { -- treesitter + 'nvim-treesitter/nvim-treesitter', + opts = function() + return require('plugins.configs.treesitter') + end, + config = function(_, opts) + -- to ensure the configuration can happen we need to do this here + -- otherwise the configuration of treesitter can't find it + require('nvim-treesitter.configs').setup(opts) + end, + init = function() + require'core.utils.lazy'('nvim-treesitter') + end, + build = ':TSUpdate', + dependencies = { + { 'nvim-treesitter/nvim-treesitter-textobjects' }, + }, + }, + + { -- rainbow-delimiters + 'hiphish/rainbow-delimiters.nvim', + config = false, + event = 'VeryLazy', + dependencies = { + 'nvim-treesitter', + }, + init = function() + vim.g.rainbow_delimiters = require'plugins.configs.treesitter.rainbow-delims' + end, + }, + + { -- nerd commenter + 'preservim/nerdcommenter', + event = 'VeryLazy', + init = function() + vim.g.NERDSpaceDelims = 1 + vim.g.NERDCompaceSexyComs = 1 + end, + keys = { + { 'cc', nil, desc = 'Comment line' }, + { 'cn', nil, desc = 'Comment line force nesting' }, + { 'c', nil, desc = 'Toggle comment selection' }, + { 'cm', nil, desc = 'Comment Minimal' }, + { 'ci', nil, desc = 'Toggle comment line' }, + { 'cs', nil, desc = 'Comment Sexy' }, + { 'cy', nil, desc = 'Comment and yank' }, + { 'c$', nil, desc = 'Comment to EOL' }, + { 'cA', nil, desc = 'Append comment' }, + { 'ca', nil, desc = 'Switch comment delimiters' }, + { 'cl', nil, desc = 'Comment align left' }, + { 'cb', nil, desc = 'Comment alight both' }, + { 'cu', nil, desc = 'Uncomment lines' }, + }, + }, + + { + 'mcauley-penney/tidy.nvim', + config = true, + event = 'BufWritePre', + }, +} diff --git a/lua/plugins/specs/lsp.lua b/lua/plugins/specs/lsp.lua new file mode 100644 index 0000000..b235cc5 --- /dev/null +++ b/lua/plugins/specs/lsp.lua @@ -0,0 +1,120 @@ +return { + + { -- mason + 'williamboman/mason.nvim', + config = true, + }, + + { -- mason-lspconfig + 'williamboman/mason-lspconfig.nvim', + dependencies = { + 'mason.nvim', + }, + }, + + { -- nvim-lspconfig + 'neovim/nvim-lspconfig', + opts = function() + return { + servers_to_not_setup = {}, + servers = { + bashls = {}, + lua_ls = { + settings = { + Lua = { + hint = { + enable = true, + arrayIndex = 'Disable', + }, + runtime = { + pathStrict = true, + }, + workspace = { + checkThirdParty = false, + }, + }, + }, + }, + pyright = { + pyright = { + autoImportCompletion = true, + }, + }, + efm = { + init_options = { documentFormatting = true }, + settings = { + rootMarkers = { '.git/' }, + languages = { + lua = { + { + formatCommand = 'stylua -s --verify --color Never -', + formatStdin = true, + }, + }, + }, + }, + }, + texlab = {}, + cssls = {}, + clangd = {}, + ts_ls = {}, + }, + setup = {}, + } + end, + init = function() + require'core.utils.lazy'('nvim-lspconfig') + end, + config = function(_, opts) + require('plugins.configs.lsp.config').setup(opts) + + require('plugins.configs.lsp.native') + end, + dependencies = { + 'mason-lspconfig.nvim', + }, + }, + + { -- lazydev + 'folke/lazydev.nvim', + ft = 'lua', + opts = {}, + }, + + { -- lspsaga + 'nvimdev/lspsaga.nvim', + event = 'LspAttach', + config = function() + require('lspsaga').setup { + code_action = { + num_shortcut = true, + show_server_name = true, + extend_gitsigns = true, + }, + lightbulb = { + enable = true, + enable_in_insert = false, + sign = true, + virtual_text = false, + }, + hover = { + open_browser = '!$BROWSER', + }, + symbol_in_winbar = { + in_custom = false, + enable = true, + seperator = '>', + show_file = true, + respect_root = true, + }, + } + end, + keys = { + { 'ld', 'Lspsaga hover_doc', desc = '[lspsaga hoverdoc]' }, + }, + dependencies = { + 'nvim-lspconfig', + 'nvim-treesitter', + }, + }, +} diff --git a/lua/plugins/specs/telescope.lua b/lua/plugins/specs/telescope.lua new file mode 100644 index 0000000..602b9cd --- /dev/null +++ b/lua/plugins/specs/telescope.lua @@ -0,0 +1,89 @@ +local telescope = {} +telescope.opts = {} + +-- default dependencies +telescope.dependencies = { ---@string[] + 'nvim-treesitter', + 'nvim-web-devicons', + 'plenary.nvim', + 'popup.nvim', + 'project.nvim', +} + + +-- This must exist even if we keep it empty for later configuration to work +telescope.opts.opts = { + defaults = { + prompt_prefix = "🔎 ", + layout_config = { + height = 0.90, + prompt_position = "top", + }, + sorting_strategy = "ascending", + dynamic_preview_title = true, + }, + pickers = {}, + extensions = { + file_browser = { + grouped = true, + hijack_netrw = true, + dir_icon = "📁", + hidden = true, + }, + }, +} + +-- TESTS for telescope-media-files +if vim.fn.executable('chafa') then + -- if chafa is installed then we set a flag and add the dependency to telescope + telescope.opts.has_chafa = true + table.insert(telescope.dependencies, 'nvim-telescope/telescope-media-files.nvim') + telescope.opts.opts.extensions.media_files = { + filetypes = { 'png', 'jpg', 'jpeg', 'webp', 'svg' }, + } +end + +-- TESTS for telescope-fzf-native +-- If not windows then attempt to build and use it. +-- We also check a global flag here that we can set if we can't build fzf-native +if vim.fn.has('win32') == 0 and not vim.g.no_fzf then + -- NOTE: has returns 0 when we don't have a feature + telescope.opts.do_fzf = true + table.insert(telescope.dependencies, 'telescope-fzf-native.nvim') +end + +-- TESTS for fzf-native +telescope.config = function(_, opts) + require('telescope').setup(opts.opts) + if opts.has_chafa then require('telescope').load_extension('media_files') end + if opts.do_fzf then require('telescope').load_extension('fzf') end + require('telescope').load_extension('projects') +end + +return { + { + 'nvim-telescope/telescope.nvim', + cmd = 'Telescope', + opts = telescope.opts, + config = telescope.config, + keys = telescope.keys, + dependencies = telescope.dependencies, + }, + + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + cond = function() + return vim.fn.has('win32') == 0 and not vim.g.no_fzf + end, + }, + + { + 'ahmedkhalf/project.nvim', + opts = { + detection_methods = { 'pattern' }, + }, + config = true, + main = 'project_nvim', + }, +} diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua new file mode 100644 index 0000000..676da0c --- /dev/null +++ b/lua/plugins/specs/ui.lua @@ -0,0 +1,124 @@ +return { + + { + 'catppuccin/nvim', + name = "catppuccin", + lazy = false, + priority = 1000, + config = function() + require'catppuccin'.setup({ + color_overrides = { + macchiato = { + text = "#feffe9", --"#b7d69b", + subtext1 = "#a8c68f", + subtext0 = "#98b381", + overlay2 = "#879f72", + overlay1 = "#758a63", + overlay0 = "#647554", + surface2 = "#526146", + surface1 = "#414d37", + surface0 = "#303828", + base = "#262e1e", + mantle = "#1d2417", + crust = "#151a10", + } + } + }) + vim.cmd([[colorscheme catppuccin-macchiato]]) + end + }, + + { -- lualine + 'nvim-lualine/lualine.nvim', + opts = function() + --return require('plugins.configs.UI.lualine') + end, + config = true, + event = 'VeryLazy', + dependencies = { + 'nvim-web-devicons', +-- 'sherlock5512/lualine-spell-status', -- custom lualine module + }, + }, + + { -- neo-tree + 'nvim-neo-tree/neo-tree.nvim', + version = '^3', + init = function() + vim.g.neo_tree_remove_legacy_commands = 1 + end, + opts = function() + return require('plugins.configs.UI.neo-tree') + end, + config = true, + -- can't lazy load as the netrw replacement functionality + -- requires hooking to be done early in the startup process + lazy = false, + dependencies = { + 'plenary.nvim', + 'nvim-web-devicons', + 'nui.nvim', + }, + keys = { + { + 'n', + 'Neotree action=focus source=filesystem position=left toggle=true', + desc = 'toggle neotree', + }, + }, + }, + + { -- zen-mode + 'folke/zen-mode.nvim', + opts = function() + return require('plugins.configs.UI.zen') + end, + config = true, + cmd = { 'ZenMode' }, + keys = { + { + 'z', + function() + require('zen-mode').toggle() + end, + desc = 'zen-mode', + }, + }, + dependencies = 'folke/twilight.nvim', + }, + + { -- trouble.nvim + 'folke/trouble.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + cmd = { + 'Trouble', + 'TroubleClose', + 'TroubleToggle', + 'TroubleRefresh', + }, + opts = {}, + }, + + { -- todo-comments + + 'folke/todo-comments.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = {}, + cmd = { + 'TodoTrouble', + 'TodoTelescope', + }, + event = { + 'BufEnter', + }, + }, + + { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim" + }, + }, + +} diff --git a/lua/plugins/specs/vimwiki.lua b/lua/plugins/specs/vimwiki.lua new file mode 100644 index 0000000..ad6e0fb --- /dev/null +++ b/lua/plugins/specs/vimwiki.lua @@ -0,0 +1,53 @@ +return { + 'vimwiki/vimwiki', + init = function() + -- Get the XDG_DOCUMENTS_DIR if it exists + -- Otherwise use `$HOME/Documents` as default + local docdir = vim.env.HOME .. '/Documents' + if vim.env.XDG_DOCUMENTS_DIR then docdir = vim.env.XDG_DOCUMENTS_DIR end + + -- Logical layout for vimwiki, also stores it in Documents + -- keeping my home directory clean + local wikiroot = docdir .. '/vimwiki' + local mainWiki = { + path = wikiroot .. '/src', + path_html = wikiroot .. '/html', + template_path = wikiroot .. '/templates', + template_default = 'default', + auto_tags = 1, -- regenerate tag file on save + auto_diary_index = 1, -- update diary index on open + auto_export = 1, -- generate HTML on save + cycle_bullets = 1, + auto_toc = 1, + } + + vim.g.vimwiki_list = { mainWiki } + vim.g.vimwiki_global_ext = 0 + vim.g.vimwiki_dir_link = 'index' + end, + + -- Perfect Lazy-loading of everything. + ft = 'vimwiki', + cmd = { + 'VimwikiIndex', + 'VimwikiTabIndex', + 'VimwikiUISelect', + 'VimwikiVar', + 'VimwikiDiaryIndex', + 'VimwikiMakeDiaryNote', + 'VimwikiTabMakeDiaryNote', + 'VimwikiMakeYesterdayDiaryNote', + 'VimwikiMakeTomorrowDiaryNote', + }, + keys = { + { 'ww', nil, desc = '[vimwiki] index' }, + { 'wt', nil, desc = '[vimwiki] index ﱚ' }, + { 'ws', nil, desc = '[vimwiki] select' }, + { 'wi', nil, desc = '[vimwiki] diary index' }, + { 'ww', nil, desc = '[vimwiki] diary today' }, + { 'wt', nil, desc = '[vimwiki] diary today ﱚ' }, + { 'wy', nil, desc = '[vimwiki] diary yesterday' }, + { 'wm', nil, desc = '[vimwiki] diary tomorrow' }, + { 't', 'VimwikiTOC', desc = '[vimwiki] TOC' }, + }, +}