From ba2ff0b63ed82cfc2687a0ce4bae24c48bc00bbc Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 17 Jan 2024 12:34:05 +0800 Subject: [PATCH] feat(lsp): Rust and cargo support --- lazy-lock.json | 23 ++++++++++++---------- lua/lazy-plugins.lua | 46 +++++++++++++++++++++++++++++++++++++++++--- lua/plugins/cmp.lua | 11 +++++------ 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 43f3726..857481b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -7,34 +7,37 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "crates.nvim": { "branch": "main", "commit": "8437522d12a8c523da2aee9db2979d070b2ecc33" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, - "dressing.nvim": { "branch": "master", "commit": "94b0d24483d56f3777ee0c8dc51675f21709318c" }, + "dressing.nvim": { "branch": "master", "commit": "c1179336aaeca82a785cade27e9b7b276af3222e" }, "friendly-snippets": { "branch": "main", "commit": "69a2c1675b66e002799f5eef803b87a12f593049" }, "gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" }, "gruvbox-material": { "branch": "master", "commit": "7f56d9f9c4860df528031539d321a61f6e081dee" }, "killersheep.nvim": { "branch": "master", "commit": "506823c47b854df02e78d5fec9468ab0e542dcf5" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" }, "mason-null-ls.nvim": { "branch": "main", "commit": "558de4372d23bd432cc3594666c4d812cd071bbf" }, "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, "neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" }, - "neogit": { "branch": "master", "commit": "bd69620be5a2f50fe0ef39236f8c0009d16e4993" }, - "none-ls.nvim": { "branch": "main", "commit": "7e146f3a188853843bb4ca1bff24c912bb9b7177" }, + "neogit": { "branch": "master", "commit": "38dd297a905ec6869f4c20ea9184a3e514316e3b" }, + "none-ls.nvim": { "branch": "main", "commit": "cf81e765460f722a381e5f3f5e3cbdce88398517" }, "nvim-bqf": { "branch": "main", "commit": "bdc2a4e5bb670b3c0e33ada9c0eec636d93a0748" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, - "nvim-lspconfig": { "branch": "master", "commit": "e47ccfae775f0d572ef0f3a7d245f043b259dafc" }, - "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, - "nvim-treesitter-context": { "branch": "master", "commit": "400a99ad43ac78af1148061da3491cba2637ad29" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" }, - "nvim-web-devicons": { "branch": "master", "commit": "584038666b0d8124d452a2e8ea9e38e6d6e56490" }, + "nvim-lspconfig": { "branch": "master", "commit": "7eed8b2150192e5ad05e1886fdf133493ddf2928" }, + "nvim-treesitter": { "branch": "master", "commit": "97ba59c6f532072e456b3d1f2413560e689c132b" }, + "nvim-treesitter-context": { "branch": "master", "commit": "2017a0d7fc2d3790d823feddedada506984a10ce" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" }, + "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "rainbow_csv.nvim": { "branch": "main", "commit": "a520dabf1c74d7d7d8341dd3f3570063ef51b3aa" }, "range-highlight.nvim": { "branch": "master", "commit": "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9" }, + "rustaceanvim": { "branch": "master", "commit": "2faa4433aaab1a398004eeb47133d98268296f96" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "master", "commit": "da8b3d485975a8727bea127518b65c980521ae22" }, - "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "7e28167b8c7e45ffceca3f10e8ef4d6dcd503393" }, + "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "f26426802a10090ab6dc5e9ac5725db00f212366" }, "vim-matchup": { "branch": "master", "commit": "e2cca1747ab175b8d839a5d28679427564643a57" }, "vim-sandwich": { "branch": "master", "commit": "c5a2cc438ce6ea2005c556dc833732aa53cae21a" } } \ No newline at end of file diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index 3aecc66..bc84f06 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -12,6 +12,9 @@ end vim.opt.rtp:prepend(lazypath) local opts = { + defaults = { + lazy = true, + }, dev = { path = "~/.local/src" }, @@ -126,6 +129,37 @@ local plugins = { "nvimtools/none-ls.nvim" } }, + + -- rust lsp support + { + 'mrcjkb/rustaceanvim', + ft = { 'rust' }, + key = { + vim.keymap.set('n', 'rr', ':RustLsp runnables'), + } + }, + { + 'saecki/crates.nvim', + tag = 'stable', + event = { "BufRead Cargo.toml" }, + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + require('crates').setup({ + null_ls = { + enabled = true, + }, + }) + -- setup cmp completion + vim.api.nvim_create_autocmd("BufRead", { + group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }), + pattern = "Cargo.toml", + callback = function() + require('cmp').setup.buffer({ sources = { { name = "crates" } } }) + end, + }) + end, + }, + -- Code editing { "machakann/vim-sandwich", @@ -196,6 +230,15 @@ local plugins = { tabout = { enable = true, hopout = true } }, }, + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = "cd app && yarn install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, + }, -- Eye candy UI { @@ -294,9 +337,6 @@ local plugins = { "sindrets/diffview.nvim", -- optional }, cmd = { "Neogit", "NeogitResetState" }, - keys = { - vim.keymap.set("n", "gi", ":Neogit") - }, opts = { disable_hint = true, }, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 8851b08..c34e16f 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -15,18 +15,17 @@ 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, }, mapping = { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.confirm({ select = true }) - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() + elseif luasnip.jumpable(1) then + luasnip.jump(1) + elseif luasnip.expandable() then + luasnip.expand() elseif has_words_before() then cmp.complete() else @@ -52,7 +51,7 @@ cmp.setup({ -- ... Your other mappings ... }, sources = cmp.config.sources({ - { name = "luasnip" }, -- For luasnip users. + { name = "luasnip", max_item_count = 4 }, -- For luasnip users. { name = "nvim_lsp" }, { name = 'nvim_lua' }, { name = "treesitter" },