diff --git a/lazy-lock.json b/lazy-lock.json index 0389c2a..827b7f9 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,15 +1,20 @@ { "LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "dichromatic": { "branch": "master", "commit": "9765a72ce24ddae48afe12c316583a22c82ad812" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, + "hererocks": { "branch": "master", "commit": "8bd2fcfdd65cfa7535ce39ea372a63b0bdb8e528" }, "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": "d88ae6623fef09251e3aa20001bb761686eae730" }, - "nvim-treesitter": { "branch": "master", "commit": "d22166e3d8d375b761c32b303176f3e955560b0c" }, + "nvim-treesitter": { "branch": "master", "commit": "b6a6d8997c46dc15682020ce4fddc5a89ee1ac0d" }, "plenary": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, diff --git a/lua/flip/lazy.lua b/lua/flip/lazy.lua index 122fb7f..6f520e4 100644 --- a/lua/flip/lazy.lua +++ b/lua/flip/lazy.lua @@ -15,15 +15,11 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- Make sure to setup `mapleader` and `maplocalleader` before --- loading lazy.nvim so that mappings are correct. This is done by loading the remap before lazy -- Setup lazy.nvim require("lazy").setup({ - spec = { - -- import plugins - { import = "plugins" }, - }, + spec = "plugins", + change_detection = { notify = false }, -- Configure any other settings here. See documentation for details install = { colorscheme = { "habamax" } }, -- automatically check for plugin updates diff --git a/lua/flip/remap.lua b/lua/flip/remap.lua index 570770d..cf67115 100644 --- a/lua/flip/remap.lua +++ b/lua/flip/remap.lua @@ -13,6 +13,9 @@ vim.keymap.set("n", "J", "mzJ`z") -- Auto formatting vim.keymap.set("n", "f", vim.lsp.buf.format) +-- Display type signature +vim.keymap.set("n", "gs", vim.lsp.buf.signature_help) + -- Greatest remap ever -- Delete visual selection to null and paste latest clipboard entry vim.keymap.set("x", "p", [["_dP]]) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 66eebcb..23a62fe 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -6,4 +6,3 @@ return { name = "plenary" } } - diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 141a5c4..b5b2a11 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,107 +1,116 @@ return { - { - "VonHeikemen/lsp-zero.nvim", - branch = "v4.x", - lazy = true, - config = false, - }, - { + "neovim/nvim-lspconfig", + dependencies = { "williamboman/mason.nvim", - lazy = false, - config = true, - }, - - -- Autocompletion - { + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - { "L3MON4D3/LuaSnip" }, - }, - config = function() - local cmp = require('cmp') - - 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 + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "j-hui/fidget.nvim", }, - -- 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') + config = function() + local cmp = require('cmp') + local cmp_lsp = require("cmp_nvim_lsp") + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_lsp.default_capabilities()) - -- 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 } + require("fidget").setup({}) + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { + "clangd", + "lua_ls", + "rust_analyzer", + }, + handlers = { + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, - 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({ + zls = function() + local lspconfig = require("lspconfig") + lspconfig.zls.setup({ + root_dir = lspconfig.util.root_pattern(".git", "build.zig", "zls.json"), 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, - }, - }, + zls = { + enable_inlay_hints = true, + enable_snippets = true, + warn_style = true, }, }, }) - end, - } + vim.g.zig_fmt_parse_errors = 0 + vim.g.zig_fmt_autosave = 0 + end, + ["lua_ls"] = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + capabilities = capabilities, + settings = { + Lua = { + runtime = { version = "Lua 5.1" }, + diagnostics = { + globals = { "bit", "vim", "it", "describe", "before_each", "after_each" }, + } + } + } + } + end, + } + }) + + local cmp_select = { behavior = cmp.SelectBehavior.Select } + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, }) - end - } + }) + + local _border = 'rounded' + + vim.diagnostic.config({ + -- update_in_insert = true, + float = { + focusable = false, + style = "minimal", + border = _border, + source = "always", + header = "", + prefix = "", + }, + }) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( + vim.lsp.handlers.hover, { border = _border } + ) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( + vim.lsp.handlers.signature_help, { border = _border } + ) + require('lspconfig.ui.windows').default_options = { border = _border } + end } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 97aff1e..1283ed5 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,7 +1,7 @@ return { "nvim-treesitter/nvim-treesitter", build = function() - require("nvim-treesitter.instal").update({ with_sync = true})() + require("nvim-treesitter.install").update({ with_sync = true })() end, config = function() require("nvim-treesitter.configs").setup({ @@ -32,7 +32,6 @@ return { }, } - vim .treesitter.language.register("templ", "templ") + vim.treesitter.language.register("templ", "templ") end } - diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua index a33d188..5a3f1c5 100644 --- a/lua/plugins/undotree.lua +++ b/lua/plugins/undotree.lua @@ -5,4 +5,3 @@ return { vim.keymap.set("n", "u", vim.cmd.UndoTreeToggle) end } -