diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 9f39e48..7fa3636 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,8 +1,15 @@ { + "LuaSnip": { "branch": "master", "commit": "45a4e899ca8f54936fe32ead6bba65f2a8d42e12" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "haskell-tools.nvim": { "branch": "1.x.x", "commit": "2c8cb26417cb4ce6f4271efb72578576464a5424" }, "kanagawa.nvim": { "branch": "master", "commit": "1749cea392acb7d1548a946fcee1e6f1304cd3cb" }, "lazy.nvim": { "branch": "main", "commit": "da8b00581a52f5f87ad2aba9f52171fda7491f18" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, + "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, "nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" }, "nvim-treesitter": { "branch": "master", "commit": "f2efc5f35743b8383a1b50f727faae94658506d5" }, "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, diff --git a/nvim/lua/configs/cmp.lua b/nvim/lua/configs/cmp.lua new file mode 100644 index 0000000..5a32204 --- /dev/null +++ b/nvim/lua/configs/cmp.lua @@ -0,0 +1,64 @@ +-- Reference: https://github.com/hrsh7th/nvim-cmp#recommended-configuration +return function() + local cmp = require "cmp" + + cmp.setup({ + 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, + }, + 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.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + 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 = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). + }, { + { 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/lua/configs/lspconfig.lua b/nvim/lua/configs/lspconfig.lua index 8959fbd..575753d 100644 --- a/nvim/lua/configs/lspconfig.lua +++ b/nvim/lua/configs/lspconfig.lua @@ -1,15 +1,19 @@ return function() local configs = require("lspconfig") + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local on_attach = function(client, buf_number) local buf_opts = { noremap = true, silent = true, buffer = buf_number } vim.keymap.set('n', 'K', vim.lsp.buf.hover, buf_opts) end configs.tsserver.setup({ - on_attach = on_attach + on_attach = on_attach, + capabilities = capabilities, }) configs.astro.setup({ - on_attach = on_attach + on_attach = on_attach, + capabilities = capabilities, }) end diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 181fd47..9795a07 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -1,8 +1,10 @@ return { + -- Telescope { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" }, }, + -- Treesitter { "nvim-treesitter/nvim-treesitter", config = require "configs/treesitter", @@ -11,14 +13,48 @@ return { vim.treesitter.language.register("markdown", "mdx") end }, + -- LSP Configs { "neovim/nvim-lspconfig", config = require "configs/lspconfig", + dependencies = { + "hrsh7th/cmp-nvim-lsp" + }, }, + -- Snippet engine + { + "L3MON4D3/LuaSnip", + }, + { + "saadparwaiz1/cmp_luasnip", + }, + -- Completion + { + "hrsh7th/cmp-nvim-lsp", + }, + { + "hrsh7th/cmp-buffer", + }, + { + "hrsh7th/cmp-path", + }, + { + "hrsh7th/cmp-cmdline", + }, + { + "hrsh7th/nvim-cmp", + config = require "configs/cmp", + dependencies = { + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, + }, + -- Rust tools { "simrat39/rust-tools.nvim", config = require "configs/rust-tools", }, + -- Haskell tools { "mrcjkb/haskell-tools.nvim", dependencies = { @@ -27,15 +63,18 @@ return { }, branch = "1.x.x", }, + -- Discord presence { "andweeb/presence.nvim", config = require "configs/presence", }, + -- Status line { "nvim-lualine/lualine.nvim", config = require "configs/lualine", dependencies = { "nvim-tree/nvim-web-devicons" }, }, + -- Editor theme { "rebelot/kanagawa.nvim", init = function()