diff --git a/lazy-lock.json b/lazy-lock.json index 9470b8d..0389c2a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,15 +1,18 @@ { + "LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "dichromatic": { "branch": "master", "commit": "9765a72ce24ddae48afe12c316583a22c82ad812" }, "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, "lsp-zero.nvim": { "branch": "v4.x", "commit": "9823b3e27deaf9f0152f3bc22f05b54f21e234e8" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, - "nvim-lspconfig": { "branch": "master", "commit": "056f569f71e4b726323b799b9cfacc53653bceb3" }, - "nvim-treesitter": { "branch": "master", "commit": "c436d45eeeeb78e5482cb28b59de1d7a77c93d86" }, - "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, + "nvim-lspconfig": { "branch": "master", "commit": "d88ae6623fef09251e3aa20001bb761686eae730" }, + "nvim-treesitter": { "branch": "master", "commit": "d22166e3d8d375b761c32b303176f3e955560b0c" }, + "plenary": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, - "telescope.nvim": { "branch": "master", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, - "vim-dichromatic": { "branch": "master", "commit": "9765a72ce24ddae48afe12c316583a22c82ad812" }, "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" } } diff --git a/lua/plugins/colors.lua b/lua/plugins/colors.lua index 6ed540d..5d57592 100644 --- a/lua/plugins/colors.lua +++ b/lua/plugins/colors.lua @@ -8,4 +8,11 @@ end vim.keymap.set("n", "c", function() ColorMyPencils() end) -ColorMyPencils() +return { + "romainl/vim-dichromatic", + name = "dichromatic", + lazy = false, + config = function() + ColorMyPencils() + end +} diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua index bb6834d..0ec521e 100644 --- a/lua/plugins/harpoon.lua +++ b/lua/plugins/harpoon.lua @@ -1,9 +1,15 @@ -local mark = require("harpoon.mark") -local ui = require("harpoon.ui") +return { + "theprimeagen/harpoon", -vim.keymap.set("n", "a", mark.add_file) -vim.keymap.set("n", "", ui.toggle_quick_menu) -vim.keymap.set("n", "1", function() ui.nav_file(1) end) -vim.keymap.set("n", "2", function() ui.nav_file(2) end) -vim.keymap.set("n", "3", function() ui.nav_file(3) end) -vim.keymap.set("n", "4", function() ui.nav_file(4) end) + config = function() + local mark = require("harpoon.mark") + local ui = require("harpoon.ui") + + vim.keymap.set("n", "a", mark.add_file) + vim.keymap.set("n", "", ui.toggle_quick_menu) + vim.keymap.set("n", "1", function() ui.nav_file(1) end) + vim.keymap.set("n", "2", function() ui.nav_file(2) end) + vim.keymap.set("n", "3", function() ui.nav_file(3) end) + vim.keymap.set("n", "4", function() ui.nav_file(4) end) + end +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 0920b60..66eebcb 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -7,26 +7,3 @@ return { } } -return { - { - "nvim-telescope/telescope.nvim", - tag = "0.1.6", - requires = { - { "nvim-lua/plenary.nvim" } } - }, - { "romainl/vim-dichromatic", config = function() vim.cmd('colorscheme dichromatic') end }, - { - "nvim-treesitter/nvim-treesitter", - build = function() - require("nvim-treesitter.install").update({ with_sync = true })() - end - }, - "nvim-treesitter/playground", - "theprimeagen/harpoon", - "mbbill/undotree", - "tpope/vim-fugitive", - { 'VonHeikemen/lsp-zero.nvim', branch = 'v4.x' }, - { 'neovim/nvim-lspconfig' }, - { 'hrsh7th/cmp-nvim-lsp' }, - { 'hrsh7th/nvim-cmp' }, -} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 406078f..141a5c4 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,46 +1,107 @@ -local lsp = require('lsp-zero').preset({}) - -lsp.ensure_installed({ - 'lua_ls', -- Lua - 'rust_analyzer', -- rust - 'texlab', -- LaTeX - 'clangd', -- C/C++ - 'jedi_language_server', -- Python - 'html', -- HTML - 'ocamllsp', -- OCaml -}) - --- Fix undefined global 'vim' -lsp.configure('lua_ls', { - cmd = { 'lua-language-server' }, - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - path = vim.split(package.path, ';'), - }, - diagnostics = { - globals = { 'vim' }, - }, - workspace = { - library = { - [vim.fn.expand('$VIMRUNTIME/lua')] = true, - [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, - }, - }, - }, +return { + { + "VonHeikemen/lsp-zero.nvim", + branch = "v4.x", + lazy = true, + config = false, + }, + { + "williamboman/mason.nvim", + lazy = false, + config = true, }, -}) -lsp.on_attach(function(_, bufnr) - lsp.default_keymaps({ buffer = bufnr }) -end) + -- Autocompletion + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + { "L3MON4D3/LuaSnip" }, + }, + config = function() + local cmp = require('cmp') -lsp.set_sign_icons({ - error = '✘', - warn = '▲', - hint = '⚑', - info = '»' -}) + cmp.setup({ + sources = { + { name = "nvim_lsp" }, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.complete(), + }), + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + }) + end + }, -lsp.setup() + -- LSP + { + "neovim/nvim-lspconfig", + cmd = { 'LspInfo', 'LspInstall', 'LspStart' }, + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + { "hrsh7th/cmp-nvim-lsp" }, + { "williamboman/mason.nvim" }, + { "williamboman/mason-lspconfig.nvim" }, + }, + config = function() + local lsp_zero = require('lsp-zero') + + -- lsp_attach is where you enable features that only work + -- if there is a language server active in the file + local lsp_attach = function(client, bufnr) + local opts = { buffer = bufnr } + + vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.keymap.set('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + vim.keymap.set('n', 'go', 'lua vim.lsp.buf.type_definition()', opts) + vim.keymap.set('n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.keymap.set('n', 'gs', 'lua vim.lsp.buf.signature_help()', opts) + vim.keymap.set('n', '', 'lua vim.lsp.buf.rename()', opts) + vim.keymap.set({ 'n', 'x' }, '', 'lua vim.lsp.buf.format({async = true})', opts) + vim.keymap.set('n', '', 'lua vim.lsp.buf.code_action()', opts) + end + + lsp_zero.extend_lspconfig({ + sign_text = true, + lsp_attach = lsp_attach, + capabilities = require('cmp_nvim_lsp').default_capabilities() + }) + + require('mason-lspconfig').setup({ + ensure_installed = {}, + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + lua_ls = function() + require('lspconfig').lua_ls.setup({ + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + path = vim.split(package.path, ';'), + }, + diagnostics = { + globals = { 'vim' }, + }, + workspace = { + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + }, + }, + }, + }, + }) + end, + } + }) + end + } +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 2b36359..93b76ac 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,6 +1,29 @@ -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'pf', builtin.find_files, {}) -vim.keymap.set('n', '', builtin.git_files, {}) -vim.keymap.set('n', 'ps', function() - builtin.grep_string({ search = vim.fn.input("Grep > ") }); -end) +return { + "nvim-telescope/telescope.nvim", + + tag = "0.1.8", + + dependencies = { + "nvim-lua/plenary.nvim" + }, + + config = function() + require('telescope').setup({}) + + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'pf', builtin.find_files, {}) + vim.keymap.set('n', '', builtin.git_files, {}) + vim.keymap.set('n', 'pws', function() + local word = vim.fn.expand("") + builtin.grep_string({ search = word }) + end) + vim.keymap.set('n', 'pWs', function() + local word = vim.fn.expand("") + builtin.grep_string({ search = word }) + end) + vim.keymap.set('n', 'ps', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) + end) + vim.keymap.set('n', 'vh', builtin.help_tags, {}) + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 8621d8e..97aff1e 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,22 +1,38 @@ -require 'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the five listed parsers should always be installed) - ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "rust", "cpp", "cmake", "latex", "python", "groovy", - "ocaml" }, +return { + "nvim-treesitter/nvim-treesitter", + build = function() + require("nvim-treesitter.instal").update({ with_sync = true})() + end, + config = function() + require("nvim-treesitter.configs").setup({ + -- List of parsers + ensure_installed = { + "vimdoc", "vim", "lua", "c", "rust", "cpp", "cmake", "latex", "python", "groovy", "bash", + }, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, + sync_install = false, + auto_install = true, - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, + indent = { + enable = true + }, - highlight = { - enable = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = { "markdown" }, + }, + }) - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, + local treesitter_parser_config = require("nvim-treesitter.parsers").get_parser_configs() + treesitter_parser_config.templ = { + install_info = { + url = "https://github.com/vrischmann/tree-sitter-templ.git", + files = { "src/parser.c", "src/scanner.c" }, + branch = "master", + }, + } + + vim .treesitter.language.register("templ", "templ") + end } + diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua index b6b9276..a33d188 100644 --- a/lua/plugins/undotree.lua +++ b/lua/plugins/undotree.lua @@ -1 +1,8 @@ -vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) +return { + "mbbill/undotree", + + config = function() + vim.keymap.set("n", "u", vim.cmd.UndoTreeToggle) + end +} + diff --git a/lua/plugins/vim-fugitive.lua b/lua/plugins/vim-fugitive.lua index 80c9070..a5b5b04 100644 --- a/lua/plugins/vim-fugitive.lua +++ b/lua/plugins/vim-fugitive.lua @@ -1 +1,6 @@ -vim.keymap.set("n", "gs", vim.cmd.Git) +return { + "tpope/vim-fugitive", + config = function() + vim.keymap.set("n", "gs", vim.cmd.Git) + end +}