From 3583fa3c2a722c634aea8a94494c826ce48f0b3c Mon Sep 17 00:00:00 2001 From: pr0c3550r Date: Sun, 5 Feb 2023 17:24:35 +0100 Subject: [PATCH] migrated to lazy.nvim --- .gitignore | 1 + nvim/.config/nvim/after/plugin/LuaSnip.lua | 14 -- .../nvim/after/plugin/indent-blankline.lua | 6 - nvim/.config/nvim/after/plugin/lspconfig.lua | 88 -------- nvim/.config/nvim/after/plugin/null-ls.lua | 12 -- nvim/.config/nvim/after/plugin/nvim-cmp.lua | 160 -------------- nvim/.config/nvim/after/plugin/telescope.lua | 5 - nvim/.config/nvim/after/plugin/treesitter.lua | 24 --- nvim/.config/nvim/init.lua | 18 +- .../nvim/lua/{user => core}/autocmd.lua | 0 .../nvim/lua/{user => core}/colors.lua | 28 +-- nvim/.config/nvim/lua/{user => core}/init.lua | 4 +- .../nvim/lua/{user => core}/packer.lua | 0 .../.config/nvim/lua/{user => core}/remap.lua | 0 .../nvim/lua/{user => core}/settings.lua | 2 +- .../nvim/lua/{user => core}/statusline.lua | 0 nvim/.config/nvim/lua/plugin/commenting.lua | 7 + nvim/.config/nvim/lua/plugin/devicons.lua | 4 + .../nvim/lua/plugin/gruvbox-material.lua | 40 ++++ .../nvim/lua/plugin/indent-blankline.lua | 12 ++ nvim/.config/nvim/lua/plugin/lspconfig.lua | 113 ++++++++++ nvim/.config/nvim/lua/plugin/null-ls.lua | 19 ++ nvim/.config/nvim/lua/plugin/nvim-cmp.lua | 195 ++++++++++++++++++ nvim/.config/nvim/lua/plugin/plenary.lua | 6 + nvim/.config/nvim/lua/plugin/telescope.lua | 19 ++ nvim/.config/nvim/lua/plugin/treesitter.lua | 32 +++ 26 files changed, 482 insertions(+), 327 deletions(-) delete mode 100644 nvim/.config/nvim/after/plugin/LuaSnip.lua delete mode 100644 nvim/.config/nvim/after/plugin/indent-blankline.lua delete mode 100644 nvim/.config/nvim/after/plugin/lspconfig.lua delete mode 100644 nvim/.config/nvim/after/plugin/null-ls.lua delete mode 100644 nvim/.config/nvim/after/plugin/nvim-cmp.lua delete mode 100644 nvim/.config/nvim/after/plugin/telescope.lua delete mode 100644 nvim/.config/nvim/after/plugin/treesitter.lua rename nvim/.config/nvim/lua/{user => core}/autocmd.lua (100%) rename nvim/.config/nvim/lua/{user => core}/colors.lua (66%) rename nvim/.config/nvim/lua/{user => core}/init.lua (65%) rename nvim/.config/nvim/lua/{user => core}/packer.lua (100%) rename nvim/.config/nvim/lua/{user => core}/remap.lua (100%) rename nvim/.config/nvim/lua/{user => core}/settings.lua (97%) rename nvim/.config/nvim/lua/{user => core}/statusline.lua (100%) create mode 100644 nvim/.config/nvim/lua/plugin/commenting.lua create mode 100644 nvim/.config/nvim/lua/plugin/devicons.lua create mode 100644 nvim/.config/nvim/lua/plugin/gruvbox-material.lua create mode 100644 nvim/.config/nvim/lua/plugin/indent-blankline.lua create mode 100644 nvim/.config/nvim/lua/plugin/lspconfig.lua create mode 100644 nvim/.config/nvim/lua/plugin/null-ls.lua create mode 100644 nvim/.config/nvim/lua/plugin/nvim-cmp.lua create mode 100644 nvim/.config/nvim/lua/plugin/plenary.lua create mode 100644 nvim/.config/nvim/lua/plugin/telescope.lua create mode 100644 nvim/.config/nvim/lua/plugin/treesitter.lua diff --git a/.gitignore b/.gitignore index d547881..559cd1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ packer_compiled.lua +lazy-lock.json diff --git a/nvim/.config/nvim/after/plugin/LuaSnip.lua b/nvim/.config/nvim/after/plugin/LuaSnip.lua deleted file mode 100644 index c0c3741..0000000 --- a/nvim/.config/nvim/after/plugin/LuaSnip.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("luasnip.loaders.from_vscode").lazy_load() - -vim.api.nvim_set_hl( 0, "PmenuSel", { fg = 'NONE', bg = '#141617' } ) -vim.api.nvim_set_hl( 0, "Pmenu", { fg = 'NONE', bg = '#1d2021' } ) - -vim.api.nvim_set_hl( 0, "CmpItemMenu", { fg = 'NONE', bg = '#141617' } ) -vim.api.nvim_set_hl( 0, "CmpItemMenuDefault", { fg = 'NONE', bg = '#141617' } ) - -vim.api.nvim_set_hl( 0, "CmpItemKindFunction", { fg = '#d3869b', bg = 'NONE', italic = true } ) -vim.api.nvim_set_hl( 0, "CmpItemKindSnippet", { fg = '#d8a657', bg = 'NONE', italic = true } ) -vim.api.nvim_set_hl( 0, "CmpItemKindText", {fg = '#ddc7a1', bg = 'NONE', italic = true } ) -vim.api.nvim_set_hl( 0, "CmpItemKindVariable", {fg = '#7daea3', bg = 'NONE', italic = true } ) --- vim.api.nvim_set_hl( 0, "", {fg = '#', bg = 'NONE', italic = true } ) - diff --git a/nvim/.config/nvim/after/plugin/indent-blankline.lua b/nvim/.config/nvim/after/plugin/indent-blankline.lua deleted file mode 100644 index bd5008f..0000000 --- a/nvim/.config/nvim/after/plugin/indent-blankline.lua +++ /dev/null @@ -1,6 +0,0 @@ -vim.opt.list = true --- vim.opt.listchars:append "space:⋅" - -require("indent_blankline").setup { - space_char_blankline = " ", -} diff --git a/nvim/.config/nvim/after/plugin/lspconfig.lua b/nvim/.config/nvim/after/plugin/lspconfig.lua deleted file mode 100644 index a5c61e6..0000000 --- a/nvim/.config/nvim/after/plugin/lspconfig.lua +++ /dev/null @@ -1,88 +0,0 @@ -local opts = { noremap = true, silent = true } -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) - -local on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'fm', function() vim.lsp.buf.format { async = true } end, bufopts) -end - -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 }) -end - - -local border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, -} - -vim.diagnostic.config({ - float = { border = border }, - virtual_text = { - prefix = '▎', -- Could be '●', '■', 'x' - } - -}) - --- LSP settings (for overriding per client) -local handlers = { - ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }), - ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }), -} - -require("mason").setup({ - ui = { - border = "rounded", - icons = { - package_installed = "✔", - package_pending = "➜", - package_uninstalled = "✘" - } - } -}) - -require("mason-lspconfig").setup({ - ensure_installed = { "sumneko_lua", "clangd" } -}) - -require("mason-lspconfig").setup_handlers { - -- The first entry (without a key) will be the default handler - -- and will be called for each installed server that doesn't have - -- a dedicated handler. - function(server_name) -- default handler (optional) - require("lspconfig")[server_name].setup { - on_attach = on_attach, - handlers = handlers, - } - end, -} diff --git a/nvim/.config/nvim/after/plugin/null-ls.lua b/nvim/.config/nvim/after/plugin/null-ls.lua deleted file mode 100644 index b4fc9a0..0000000 --- a/nvim/.config/nvim/after/plugin/null-ls.lua +++ /dev/null @@ -1,12 +0,0 @@ -local null_ls = require('null-ls') - -local sources = { - null_ls.builtins.diagnostics.trail_space.with{ - disabled_filetypes = { "lua" } - }, - null_ls.builtins.diagnostics.shellcheck, -} - -null_ls.setup({ - sources = sources, -}) diff --git a/nvim/.config/nvim/after/plugin/nvim-cmp.lua b/nvim/.config/nvim/after/plugin/nvim-cmp.lua deleted file mode 100644 index 99c9e19..0000000 --- a/nvim/.config/nvim/after/plugin/nvim-cmp.lua +++ /dev/null @@ -1,160 +0,0 @@ --- Set up nvim-cmp with luasnip - -local kind_icons = { - Text = "", - Method = "", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "ﴯ", - Interface = "", - Module = "", - Property = "ﰠ", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "" -} - -local 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 - -local luasnip = require("luasnip") -local cmp = require'cmp' - -cmp.setup({ - formatting = { - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind - -- Source - vim_item.menu = ({ - -- buffer = "[Buffer]", - -- nvim_lsp = "[LSP]", - -- luasnip = "[LuaSnip]", - -- nvim_lua = "[Lua]", - -- latex_symbols = "[LaTeX]", - buffer = "", - nvim_lsp = "", - luasnip = "", - nvim_lua = "", - latex_symbols = "", - })[entry.source.name] - return vim_item - end - }, - - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - end, - }, - - -- completion = { - -- autocomplete = false, - -- }, - - 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(function(fallback) - if cmp.visible() then - cmp.abort() - else - cmp.complete() - end - end), - [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() - -- they way you will only jump inside the snippet region - 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 = 'vsnip' }, -- For vsnip users. - { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. - { name = 'buffer' }, - }, { - }) -}) --- Set configuration for specific filetype. -cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { name = 'buffer' }, - }) -}) - --- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) -}) - --- Set up lspconfig. --- local capabilities = require('cmp_nvim_lsp').default_capabilities() --- -- Replace with each lsp server you've enabled. --- require('lspconfig')[''].setup { - -- capabilities = capabilities - -- } diff --git a/nvim/.config/nvim/after/plugin/telescope.lua b/nvim/.config/nvim/after/plugin/telescope.lua deleted file mode 100644 index 5a32c3a..0000000 --- a/nvim/.config/nvim/after/plugin/telescope.lua +++ /dev/null @@ -1,5 +0,0 @@ -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fg', builtin.live_grep, {}) -vim.keymap.set('n', 'fG', builtin.git_files, {}) - diff --git a/nvim/.config/nvim/after/plugin/treesitter.lua b/nvim/.config/nvim/after/plugin/treesitter.lua deleted file mode 100644 index 97f8edb..0000000 --- a/nvim/.config/nvim/after/plugin/treesitter.lua +++ /dev/null @@ -1,24 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" - ensure_installed = { "c", "lua", "rust", "latex", "bibtex", "python", "vim" }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - - highlight = { - -- `false` will disable the whole extension - enable = true, - - -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to - -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is - -- the name of the parser) - -- list of language that will be disabled - disable = { "markdown" }, - -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files - additional_vim_regex_highlighting = false, - }, -} diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index ea49ffa..5427c17 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1 +1,17 @@ -require("user") +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("core.settings") +require("core.remap") +require("lazy").setup("plugin") +require("core.autocmd") diff --git a/nvim/.config/nvim/lua/user/autocmd.lua b/nvim/.config/nvim/lua/core/autocmd.lua similarity index 100% rename from nvim/.config/nvim/lua/user/autocmd.lua rename to nvim/.config/nvim/lua/core/autocmd.lua diff --git a/nvim/.config/nvim/lua/user/colors.lua b/nvim/.config/nvim/lua/core/colors.lua similarity index 66% rename from nvim/.config/nvim/lua/user/colors.lua rename to nvim/.config/nvim/lua/core/colors.lua index d0f354b..cc42d4f 100644 --- a/nvim/.config/nvim/lua/user/colors.lua +++ b/nvim/.config/nvim/lua/core/colors.lua @@ -1,21 +1,21 @@ -- setting colors -- everforest -vim.api.nvim_set_var("everforest_background", "hard") -vim.api.nvim_set_var("everforest_transparent_background", "1") -vim.api.nvim_set_var("everforest_ui_contrast", "low") -vim.api.nvim_set_var("everforest_show_eob", "0") -vim.api.nvim_set_var("everforest_enable_bold", "1") -vim.api.nvim_set_var("everforest_enable_italic", "1") -vim.api.nvim_set_var("everforest_better_performance", "1") +-- vim.api.nvim_set_var("everforest_background", "hard") +-- vim.api.nvim_set_var("everforest_transparent_background", "1") +-- vim.api.nvim_set_var("everforest_ui_contrast", "low") +-- vim.api.nvim_set_var("everforest_show_eob", "0") +-- vim.api.nvim_set_var("everforest_enable_bold", "1") +-- vim.api.nvim_set_var("everforest_enable_italic", "1") +-- vim.api.nvim_set_var("everforest_better_performance", "1") -- gruvbox -vim.api.nvim_set_var("gruvbox_material_background", "hard") -vim.api.nvim_set_var("gruvbox_material_transparent_background", "1") -vim.api.nvim_set_var("gruvbox_material_ui_contrast", "low") -vim.api.nvim_set_var("gruvbox_material_show_eob", "0") -vim.api.nvim_set_var("gruvbox_material_enable_bold", "1") -vim.api.nvim_set_var("gruvbox_material_enable_italic", "1") -vim.api.nvim_set_var("gruvbox_material_better_performance", "1") +-- vim.api.nvim_set_var("gruvbox_material_background", "hard") +-- vim.api.nvim_set_var("gruvbox_material_transparent_background", "1") +-- vim.api.nvim_set_var("gruvbox_material_ui_contrast", "low") +-- vim.api.nvim_set_var("gruvbox_material_show_eob", "0") +-- vim.api.nvim_set_var("gruvbox_material_enable_bold", "1") +-- vim.api.nvim_set_var("gruvbox_material_enable_italic", "1") +-- vim.api.nvim_set_var("gruvbox_material_better_performance", "1") -- setting colorscheme vim.cmd [[colo gruvbox-material]] diff --git a/nvim/.config/nvim/lua/user/init.lua b/nvim/.config/nvim/lua/core/init.lua similarity index 65% rename from nvim/.config/nvim/lua/user/init.lua rename to nvim/.config/nvim/lua/core/init.lua index 41c4a0b..4b94dec 100644 --- a/nvim/.config/nvim/lua/user/init.lua +++ b/nvim/.config/nvim/lua/core/init.lua @@ -1,7 +1,7 @@ -require("user.packer") +-- require("user.packer") require("user.settings") require("user.remap") require("user.autocmd") require("user.statusline") -require("user.colors") +-- require("user.colors") diff --git a/nvim/.config/nvim/lua/user/packer.lua b/nvim/.config/nvim/lua/core/packer.lua similarity index 100% rename from nvim/.config/nvim/lua/user/packer.lua rename to nvim/.config/nvim/lua/core/packer.lua diff --git a/nvim/.config/nvim/lua/user/remap.lua b/nvim/.config/nvim/lua/core/remap.lua similarity index 100% rename from nvim/.config/nvim/lua/user/remap.lua rename to nvim/.config/nvim/lua/core/remap.lua diff --git a/nvim/.config/nvim/lua/user/settings.lua b/nvim/.config/nvim/lua/core/settings.lua similarity index 97% rename from nvim/.config/nvim/lua/user/settings.lua rename to nvim/.config/nvim/lua/core/settings.lua index 4bb62e7..7f9df56 100644 --- a/nvim/.config/nvim/lua/user/settings.lua +++ b/nvim/.config/nvim/lua/core/settings.lua @@ -38,7 +38,7 @@ vim.api.nvim_set_option("scrolloff",999) -- spellchecking vim.wo.spell = true -vim.bo.spelllang = "de,en_us" +vim.bo.spelllang = "de" -- highlight the current linenumber vim.wo.cursorline = true diff --git a/nvim/.config/nvim/lua/user/statusline.lua b/nvim/.config/nvim/lua/core/statusline.lua similarity index 100% rename from nvim/.config/nvim/lua/user/statusline.lua rename to nvim/.config/nvim/lua/core/statusline.lua diff --git a/nvim/.config/nvim/lua/plugin/commenting.lua b/nvim/.config/nvim/lua/plugin/commenting.lua new file mode 100644 index 0000000..a9e505e --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/commenting.lua @@ -0,0 +1,7 @@ +return { + { + "tpope/vim-commentary", + event = "BufReadPost", + }, +} + diff --git a/nvim/.config/nvim/lua/plugin/devicons.lua b/nvim/.config/nvim/lua/plugin/devicons.lua new file mode 100644 index 0000000..a5b320d --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/devicons.lua @@ -0,0 +1,4 @@ +return { + "nvim-tree/nvim-web-devicons", + lazy = true, +} diff --git a/nvim/.config/nvim/lua/plugin/gruvbox-material.lua b/nvim/.config/nvim/lua/plugin/gruvbox-material.lua new file mode 100644 index 0000000..5ec0d72 --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/gruvbox-material.lua @@ -0,0 +1,40 @@ +return { + { + "sainnhe/gruvbox-material", + priority = 1000, + config = function() + -- Settings for colorscheme + vim.api.nvim_set_var("gruvbox_material_background", "hard") + vim.api.nvim_set_var("gruvbox_material_transparent_background", "1") + vim.api.nvim_set_var("gruvbox_material_ui_contrast", "low") + vim.api.nvim_set_var("gruvbox_material_show_eob", "0") + vim.api.nvim_set_var("gruvbox_material_enable_bold", "1") + vim.api.nvim_set_var("gruvbox_material_enable_italic", "1") + vim.api.nvim_set_var("gruvbox_material_better_performance", "1") + vim.cmd([[colo gruvbox-material]]) + + -- Settings to override colorscheme + vim.api.nvim_set_hl(0, "ModeMsg", { bold = true, fg = "#d8a657"}) + -- colors of tabline + vim.api.nvim_set_hl(0, "TabLine", {bg = "#3c3836", fg = "#89b482"}) + vim.api.nvim_set_hl(0, "TabLineFil", {bg = "#1d2021"}) + vim.api.nvim_set_hl(0, "TabLineSel", {bold = true, bg = "none", fg = "#d8a657"}) + -- color of statusline + vim.api.nvim_set_hl(0, "StatusLine", {bold = false, bg = "#1d2021", fg = "#89b482"}) + vim.api.nvim_set_hl(0, "StatusLineNC", {bg = "#1d2021", fg = "#5b534d"}) + -- color of vertical split line + vim.api.nvim_set_hl(0, "VertSplit", {bg = "#141617", fg = "#141617"}) + -- color of the cursorline and cursorlinenumber + vim.api.nvim_set_hl(0, "Cursorline", {bg = "#141617"}) + vim.api.nvim_set_hl(0, "CursorLineNr", {bold = true, bg = "#141617", fg = "#d8a657"}) + -- color of Floats and FloatBorders + vim.api.nvim_set_hl(0, "NormalFloat", {bg = none, fg = none }) + vim.api.nvim_set_hl(0, "FloatBorder", {bg = none, fg = "#d4be98"}) + vim.api.nvim_set_hl(0, "DiagnosticFloatingWarn", {bg = none, fg = "#d8a657"}) + vim.api.nvim_set_hl(0, "DiagnosticFloatingError", {bg = none, fg = "#ea6962"}) + vim.api.nvim_set_hl(0, "DiagnosticFloatingHint", {bg = none, fg = "#a9b665"}) + vim.api.nvim_set_hl(0, "DiagnosticFloatingInfo", {bg = none, fg = "#d4be98"}) + end, + }, +} + diff --git a/nvim/.config/nvim/lua/plugin/indent-blankline.lua b/nvim/.config/nvim/lua/plugin/indent-blankline.lua new file mode 100644 index 0000000..c3f0482 --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/indent-blankline.lua @@ -0,0 +1,12 @@ +return { + { + "lukas-reineke/indent-blankline.nvim", + event = "BufReadPre", + opts = { + -- char = "│", + filetype_exclude = { "help", "lazy" }, + show_trailing_blankline_indent = true, + show_current_context = true, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugin/lspconfig.lua b/nvim/.config/nvim/lua/plugin/lspconfig.lua new file mode 100644 index 0000000..8456f68 --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/lspconfig.lua @@ -0,0 +1,113 @@ +return { + { + "neovim/nvim-lspconfig", + event = "BufReadPre", + config = function() + + local opts = { noremap = true, silent = true } + vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) + vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) + vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + + local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'fm', function() vim.lsp.buf.format { async = true } end, bufopts) + end + + 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 }) + end + + + local border = { + { "╭", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, + { "╯", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, + { "│", "FloatBorder" }, + } + + vim.diagnostic.config({ + float = { border = border }, + virtual_text = { + prefix = '▎', -- Could be '●', '■', 'x' + } + + }) + + -- LSP settings (for overriding per client) + local handlers = { + ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }), + ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }), + } + end, + }, + + { + "williamboman/mason.nvim", + cmd = "Mason", + config = function() + require("mason").setup({ + ui = { + border = "rounded", + icons = { + package_installed = "✔", + package_pending = "➜", + package_uninstalled = "✘" + } + } + }) + end, + }, + + { + "williamboman/mason-lspconfig.nvim", + event = "BufReadPre", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { + "sumneko_lua", + "clangd", + } + }) + + require("mason-lspconfig").setup_handlers { + -- The first entry (without a key) will be the default handler + -- and will be called for each installed server that doesn't have + -- a dedicated handler. + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup { + on_attach = on_attach, + handlers = handlers, + } + end, + } + end, + }, +} + diff --git a/nvim/.config/nvim/lua/plugin/null-ls.lua b/nvim/.config/nvim/lua/plugin/null-ls.lua new file mode 100644 index 0000000..55d02d2 --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/null-ls.lua @@ -0,0 +1,19 @@ +return { + { + "jose-elias-alvarez/null-ls.nvim", + event = "BufReadPost", + opts = function() + local null_ls = require('null-ls') + return { + sources = { + null_ls.builtins.diagnostics.trail_space.with{ + disabled_filetypes = { "lua" } + }, + null_ls.builtins.diagnostics.shellcheck, + }, + } + end, + + }, +} + diff --git a/nvim/.config/nvim/lua/plugin/nvim-cmp.lua b/nvim/.config/nvim/lua/plugin/nvim-cmp.lua new file mode 100644 index 0000000..4fd30f9 --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/nvim-cmp.lua @@ -0,0 +1,195 @@ +return { + + -- snippets + { + "L3MON4D3/LuaSnip", + lazy = true, + dependencies = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + vim.api.nvim_set_hl( 0, "PmenuSel", { fg = 'NONE', bg = '#141617' } ) + vim.api.nvim_set_hl( 0, "Pmenu", { fg = 'NONE', bg = '#1d2021' } ) + vim.api.nvim_set_hl( 0, "CmpItemMenu", { fg = 'NONE', bg = '#141617' } ) + vim.api.nvim_set_hl( 0, "CmpItemMenuDefault", { fg = 'NONE', bg = '#141617' } ) + vim.api.nvim_set_hl( 0, "CmpItemKindFunction", { fg = '#d3869b', bg = 'NONE', italic = true } ) + vim.api.nvim_set_hl( 0, "CmpItemKindSnippet", { fg = '#d8a657', bg = 'NONE', italic = true } ) + vim.api.nvim_set_hl( 0, "CmpItemKindText", {fg = '#ddc7a1', bg = 'NONE', italic = true } ) + vim.api.nvim_set_hl( 0, "CmpItemKindVariable", {fg = '#7daea3', bg = 'NONE', italic = true } ) + end, + }, + }, + + -- completion + { + "hrsh7th/nvim-cmp", + version = false, + event = { + -- "InsertEnter", + -- "CmdlineEnter", + "BufWinEnter", + }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + }, + opts = function() + -- Set up nvim-cmp with luasnip + local kind_icons = { + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "ﴯ", + Interface = "", + Module = "", + Property = "ﰠ", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "" + } + + local 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 + + local luasnip = require("luasnip") + local cmp = require("cmp") + + return{ + formatting = { + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + -- Source + vim_item.menu = ({ + -- buffer = "[Buffer]", + -- nvim_lsp = "[LSP]", + -- luasnip = "[LuaSnip]", + -- nvim_lua = "[Lua]", + -- latex_symbols = "[LaTeX]", + buffer = "", + nvim_lsp = "", + luasnip = "", + nvim_lua = "", + latex_symbols = "", + })[entry.source.name] + return vim_item + end + }, + + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, + }, + + -- completion = { + -- autocomplete = false, + -- }, + + 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(function(fallback) + if cmp.visible() then + cmp.abort() + else + cmp.complete() + end + end), + [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + 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 = 'vsnip' }, -- For vsnip users. + { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + { name = 'buffer' }, + }, { + }), + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) + }), + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }), + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }), + } + end, + } +} diff --git a/nvim/.config/nvim/lua/plugin/plenary.lua b/nvim/.config/nvim/lua/plugin/plenary.lua new file mode 100644 index 0000000..0fe75df --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/plenary.lua @@ -0,0 +1,6 @@ +return { + { + "nvim-lua/plenary.nvim", + lazy = true, + }, +} diff --git a/nvim/.config/nvim/lua/plugin/telescope.lua b/nvim/.config/nvim/lua/plugin/telescope.lua new file mode 100644 index 0000000..3602661 --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/telescope.lua @@ -0,0 +1,19 @@ +return { + { + "nvim-telescope/telescope.nvim", + lazy = true, + cmd = "Telescope", + version = false, + keys = { + { ":", "Telescope command_history", desc = "Command History" }, + { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, + -- find + {"ff", "Telescope find_files", desc = "Find Files" }, + {"fg", "Telescope live_grep", desc = "Grep Content in Files" }, + {"/", "Telescope live_grep", desc = "Grep Content in Files" }, + {"fG", "Telescope git_files", desc = "Find Git Files" }, + {"fk", "Telescope keymaps", desc = "Find Git Files" }, + + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugin/treesitter.lua b/nvim/.config/nvim/lua/plugin/treesitter.lua new file mode 100644 index 0000000..fdc862b --- /dev/null +++ b/nvim/.config/nvim/lua/plugin/treesitter.lua @@ -0,0 +1,32 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + version = false, + build = ":TSUpdate", + event = "BufReadPost", + opts = { + ensure_installed = { + "c", + "lua", + "rust", + "latex", + "bibtex", + "python", + "vim", + "yaml", + "json", + }, + sync_install = false, + auto_install = true, + highlight = { + enable = true, + disable = { + "markdown", + }, + }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + } +}