diff --git a/nvim/nvim/lazy-lock.json b/nvim/nvim/lazy-lock.json index 47d1fdc..93e223e 100644 --- a/nvim/nvim/lazy-lock.json +++ b/nvim/nvim/lazy-lock.json @@ -1,15 +1,27 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "82108e7e31cc6fc223cc5df5cae6d89f70bb199f" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "copilot.vim": { "branch": "release", "commit": "1a55183ef9347d6f420406a3746474b6b9fb9ef5" }, + "fidget.nvim": { "branch": "main", "commit": "3a93300c076109d86c7ce35ec67a8034ae6ba9db" }, "gitsigns": { "branch": "main", "commit": "3e6e91b09f0468c32d3b96dcacf4b947f037ce25" }, "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, "lush": { "branch": "main", "commit": "e8a58f36c256af65cda36878f6f2024a612154c3" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, + "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, "mellifluous.nvim": { "branch": "main", "commit": "d4a52152997907598715d341cad10a4000cf7152" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" }, "nvim-tree.lua": { "branch": "master", "commit": "b8c3a23e76f861d5f0ff3f6714b9b56388984d0b" }, "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, "plenary": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, - "telescope.nvim": { "branch": "master", "commit": "87e92ea31b2b61d45ad044cf7b2d9b66dad2a618" }, + "telescope.nvim": { "branch": "master", "commit": "b3ff5f33201f474d58f5be96244869f189bbc091" }, "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" } } \ No newline at end of file diff --git a/nvim/nvim/lua/mimu/init.lua b/nvim/nvim/lua/mimu/init.lua index 4219cd8..521d7dc 100644 --- a/nvim/nvim/lua/mimu/init.lua +++ b/nvim/nvim/lua/mimu/init.lua @@ -2,3 +2,26 @@ require("mimu.set") require("mimu.remap") require("mimu.lazy") +local augroup = vim.api.nvim_create_augroup +local MimuGroup = augroup("mimu", {}) + +local autocmd = vim.api.nvim_create_autocmd + +vim.cmd [[autocmd BufWritePre lua vim.lsp.buf.format()]] + +autocmd("LspAttach", { + group = MimuGroup, + callback = function(e) + local opts = { buffer = e.buf } + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "gr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.lsp.diagnostic.open_float() end, opts) + -- vim.keymap.set("n", "[d", function() vim.lsp.diagnostic.goto_next() end, opts) + -- vim.keymap.set("n", "]d", function() vim.lsp.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) + end +}) diff --git a/nvim/nvim/lua/mimu/lazy.lua b/nvim/nvim/lua/mimu/lazy.lua index cc98e71..8afb4d0 100644 --- a/nvim/nvim/lua/mimu/lazy.lua +++ b/nvim/nvim/lua/mimu/lazy.lua @@ -11,4 +11,7 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) -require("lazy").setup("mimu.plugins") +require("lazy").setup({ + spec = "mimu.plugins", + change_detection = { notify = false }, +}) diff --git a/nvim/nvim/lua/mimu/plugins/basics.lua b/nvim/nvim/lua/mimu/plugins/basics.lua index 17022bd..15bee4e 100644 --- a/nvim/nvim/lua/mimu/plugins/basics.lua +++ b/nvim/nvim/lua/mimu/plugins/basics.lua @@ -16,23 +16,11 @@ return { end, }, - -- telescope { "nvim-lua/plenary.nvim", name = "plenary" }, - -- trouble / diagnostics - { - "folke/trouble.nvim", - config = function() - require("trouble").setup({ - icons = false, - }) - end - }, - - -- fugitive / git { "lewis6991/gitsigns.nvim", name = "gitsigns", @@ -47,5 +35,7 @@ return { end }, + "github/copilot.vim", + } diff --git a/nvim/nvim/lua/mimu/plugins/lsp.lua b/nvim/nvim/lua/mimu/plugins/lsp.lua new file mode 100644 index 0000000..3bea636 --- /dev/null +++ b/nvim/nvim/lua/mimu/plugins/lsp.lua @@ -0,0 +1,98 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/nvim-cmp", + "j-hui/fidget.nvim", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, + + config = function() + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + require("fidget").setup() + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + "rust_analyzer", + "clangd", + "gopls", + "tsserver", + }, + handlers = { + function (server_name) -- default handler (optional) + + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, + + ["lua_ls"] = function () + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + settings = { + Lua = { + diagnostics = { + globals = { "vim" } + } + } + } + } + end, + } + }) + + local cmp = require("cmp") + local cmp_select = { behaviour = cmp.SelectBehavior.Select } + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.confirm({ select = true }), + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + }) + }) + + vim.diagnostic.config({ + virtual_text = true, + update_on_insert = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + }) + end +} diff --git a/nvim/nvim/lua/mimu/plugins/trouble.lua b/nvim/nvim/lua/mimu/plugins/trouble.lua new file mode 100644 index 0000000..950f638 --- /dev/null +++ b/nvim/nvim/lua/mimu/plugins/trouble.lua @@ -0,0 +1,33 @@ +return { + "folke/trouble.nvim", + config = function() + require("trouble").setup({ + icons = false, + fold_open = "v", -- icon used for open folds + fold_closed = ">", -- icon used for closed folds + indent_lines = false, -- add an indent guide below the fold icons + signs = { + -- icons / text used for a diagnostic + error = "error", + warning = "warn", + hint = "hint", + information = "info" + }, + use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client + }) + + vim.keymap.set("n", "tt", function() + require("trouble").toggle() + end) + + vim.keymap.set("n", "[d", function() + require("trouble").next({skip_groups = true, jump = true}) + end) + + vim.keymap.set("n", "]d", function() + require("trouble").previous({skip_groups = true, jump = true}) + end) + end +} + + diff --git a/nvim/nvim/lua/mimu/set.lua b/nvim/nvim/lua/mimu/set.lua index 211e5a0..cea4de0 100644 --- a/nvim/nvim/lua/mimu/set.lua +++ b/nvim/nvim/lua/mimu/set.lua @@ -1,5 +1,3 @@ -vim.cmd [[autocmd BufWritePre lua vim.lsp.buf.format()]] - vim.opt.nu = true vim.opt.relativenumber = true