From 15121db53cd12ba8bdaafeebd04ca20e0b076fd2 Mon Sep 17 00:00:00 2001 From: Uttarayan Mondal Date: Fri, 12 Jan 2024 12:11:38 +0530 Subject: [PATCH] [fix] Update plugins and use inlayHints from nvim 0.10 --- config/nushell/config.nu | 1 + config/nvim/init.lua | 10 ++ config/nvim/lazy-lock.json | 40 ++--- config/nvim/lua/colorscheme.lua | 1 + config/nvim/lua/keymaps.lua | 2 +- config/nvim/lua/lsp.lua | 8 +- config/nvim/lua/plugins.lua | 29 ++- config/nvim/lua/setup/rtools.lua | 295 ++++++------------------------- 8 files changed, 115 insertions(+), 271 deletions(-) diff --git a/config/nushell/config.nu b/config/nushell/config.nu index 687de614..d1d2fa23 100644 --- a/config/nushell/config.nu +++ b/config/nushell/config.nu @@ -562,3 +562,4 @@ source zoxide.nu source alias.nu source cargo.nu use conda.nu +macchina diff --git a/config/nvim/init.lua b/config/nvim/init.lua index e8f9d4e9..18ce623d 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -113,3 +113,13 @@ require 'nvim-treesitter.configs'.setup { additional_vim_regex_highlighting = false, }, } +require('nvim-treesitter.install').compilers = { "gcc-11", "clang" } +require('nvim-treesitter.parsers').get_parser_configs().just = { + install_info = { + url = "https://github.com/IndianBoy42/tree-sitter-just", -- local path or git repo + files = { "src/parser.c", "src/scanner.cc" }, + branch = "main", + use_makefile = true, -- this may be necessary on MacOS (try if you see compiler errors) + }, + maintainers = { "@IndianBoy42" }, +} diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json index e304c147..cd07b793 100644 --- a/config/nvim/lazy-lock.json +++ b/config/nvim/lazy-lock.json @@ -1,56 +1,56 @@ { - "LuaSnip": { "branch": "master", "commit": "2463d687fe704b76eb0aa3bb34e95f69a5bb0362" }, + "LuaSnip": { "branch": "master", "commit": "82108e7e31cc6fc223cc5df5cae6d89f70bb199f" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, - "cmp-git": { "branch": "main", "commit": "f900a4cf117300fdc3ba31d26f8b6223ccd9c574" }, + "cmp-git": { "branch": "main", "commit": "8d8993680d627c8f13bd85094eba84604107dbdd" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "comfortable-motion.vim": { "branch": "master", "commit": "e20aeafb07c6184727b29f7674530150f7ab2036" }, "copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" }, - "copilot.lua": { "branch": "master", "commit": "858bbfa6fa81c88fb1f64107d7981f1658619e0a" }, + "copilot.lua": { "branch": "master", "commit": "b03617a6dc4bc88b65ab5deac1631da9a9c2dcaf" }, "d2-vim": { "branch": "master", "commit": "981c87dccb63df2887cc41b96e84bf550f736c57" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, - "fidget.nvim": { "branch": "main", "commit": "a4a7edfea37e557dbff5509ee374ffb57051bba9" }, + "fidget.nvim": { "branch": "main", "commit": "3a93300c076109d86c7ce35ec67a8034ae6ba9db" }, "formatter.nvim": { "branch": "master", "commit": "cb4778b8432f1ae86dae4634c0b611cb269a4c2f" }, "galaxyline.nvim": { "branch": "main", "commit": "4d4f5fc8e20a10824117e5beea7ec6e445466a8f" }, "git-conflict.nvim": { "branch": "main", "commit": "4e0191c9a0ae05d7fbdcdc7f15cd358f56d23bfb" }, "glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" }, - "indent-blankline.nvim": { "branch": "master", "commit": "5da5546947f3125dfd6aa85ab21074dc83f776d5" }, + "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lazygit.nvim": { "branch": "main", "commit": "1e08e3f5ac1152339690140e61a4a32b3bdc7de5" }, "lsp-status.nvim": { "branch": "master", "commit": "54f48eb5017632d81d0fd40112065f1d062d0629" }, - "lspsaga.nvim": { "branch": "main", "commit": "e71cddc9d4c1dd97c026814777b810df988daed2" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, - "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, + "lspsaga.nvim": { "branch": "main", "commit": "3112b7aba57653199ad20198f477d94781bb2310" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, + "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, "mini.nvim": { "branch": "main", "commit": "b5645ac6eefce8e7af9d7dd4e5e296a81cba8a10" }, - "neorg": { "branch": "main", "commit": "9021c7c7eefc1e11a8f1591f8cba5e118405336b" }, + "neorg": { "branch": "main", "commit": "5432be2500f52d32a0a5a63ee4557ce592a6aecf" }, "no-neck-pain.nvim": { "branch": "main", "commit": "b305821ca45897db6276e9ae5893747bb24040c7" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, - "nvim-dap": { "branch": "master", "commit": "f0dca670fa059eb89dda8869a6310c804241345c" }, - "nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" }, - "nvim-lspconfig": { "branch": "master", "commit": "9099871a7c7e1c16122e00d70208a2cd02078d80" }, + "nvim-dap": { "branch": "master", "commit": "aad46274f09ba29933e4cef2257cdda5ec19cf7a" }, + "nvim-dap-ui": { "branch": "master", "commit": "7e5e16427aaf814dc2d58e1b219def9ef2fa2435" }, + "nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" }, "nvim-nu": { "branch": "main", "commit": "f45f36a97fb0ea6e39f08cc2fac7a2fb3dc3999b" }, - "nvim-treesitter": { "branch": "master", "commit": "7d0b4756aba3b220d38ec0443c6cc10944060dd7" }, - "nvim-treesitter-context": { "branch": "master", "commit": "652ec514d6ba8bc4a3c2de76c855fe668e2c7196" }, - "nvim-web-devicons": { "branch": "master", "commit": "43aa2ddf476012a2155f5f969ee55ab17174da7a" }, - "octo.nvim": { "branch": "master", "commit": "4a60f50bb886572a59fde095b990fa28e2b50dba" }, + "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, + "nvim-treesitter-context": { "branch": "master", "commit": "400a99ad43ac78af1148061da3491cba2637ad29" }, + "nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" }, + "octo.nvim": { "branch": "master", "commit": "051b633edaf7ce7bf885fe809782c433386b5e6f" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "rest.nvim": { "branch": "main", "commit": "84e81a19ab24ccf05c9233d34d4dfce61c233abe" }, "ron.vim": { "branch": "master", "commit": "f749e543975a82e8dd9a6e7df9600a1c098ae800" }, - "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, + "rustaceanvim": { "branch": "master", "commit": "d03f72788b81cb311250d9fe0692f3435d609b5a" }, "sonokai": { "branch": "master", "commit": "bdce098fc9e7202d3c555e2dc98c755ca1c23835" }, "ssr.nvim": { "branch": "main", "commit": "bb323ba621ac647b4ac5638b47666e3ef3c279e1" }, "suda.vim": { "branch": "master", "commit": "8b0fc3711760195aba104e2d190cff9af8267052" }, - "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "e0651458f2ced647f3ff3c89d5663244b3cf45af" }, + "telescope.nvim": { "branch": "master", "commit": "da8b3d485975a8727bea127518b65c980521ae22" }, "todo-comments.nvim": { "branch": "main", "commit": "4a6737a8d70fe1ac55c64dfa47fcb189ca431872" }, "toggleterm.nvim": { "branch": "main", "commit": "e3805fed94d487b81e9c21548535cc820f62f840" }, - "tree-sitter-just": { "branch": "main", "commit": "4e5f5f3ff37b12a1bbf664eb3966b3019e924594" }, + "tree-sitter-just": { "branch": "main", "commit": "f807ab33c36651ecb503a291aed933932754864d" }, "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, "vim-abolish": { "branch": "master", "commit": "dcbfe065297d31823561ba787f51056c147aa682" }, "vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" }, diff --git a/config/nvim/lua/colorscheme.lua b/config/nvim/lua/colorscheme.lua index 2843d392..4f6d033f 100644 --- a/config/nvim/lua/colorscheme.lua +++ b/config/nvim/lua/colorscheme.lua @@ -41,3 +41,4 @@ vim.cmd('hi NormalNC guibg=' .. colors.black) vim.cmd('hi EndOfBuffer guibg=' .. colors.black) -- vim.cmd('hi ToggleTerm1Buffer guibg='..colors.black) vim.cmd('hi NonText guibg=' .. colors.black) +vim.cmd('hi LspInlayHint guifg=' .. colors.bg4) diff --git a/config/nvim/lua/keymaps.lua b/config/nvim/lua/keymaps.lua index b0f703d5..40a7d902 100644 --- a/config/nvim/lua/keymaps.lua +++ b/config/nvim/lua/keymaps.lua @@ -47,7 +47,7 @@ local normal_mode_maps = { { key = 'fh', map = [[lua require('telescope.builtin').help_tags()]] }, { key = 'gB', map = [[Git blame]] }, { key = 'rd', map = [[RustDebuggables]] }, - { key = 'rr', map = [[RustRunnables]] }, + -- { key = 'rr', map = vim.cmd.RustLsp('runnables') }, { key = 'vff', map = [[vertical Gdiffsplit]] }, -- { key = 'vff!', map = [[vertical Gdiffsplit!]] }, -- { key = 'ssr', map = [[lua require'rust-tools'.ssr.ssr(query)]] }, diff --git a/config/nvim/lua/lsp.lua b/config/nvim/lua/lsp.lua index c977f6d9..9aef8878 100644 --- a/config/nvim/lua/lsp.lua +++ b/config/nvim/lua/lsp.lua @@ -6,12 +6,16 @@ local capabilities = cmp_nvim_lsp.default_capabilities() require("mason-lspconfig").setup_handlers { function(server_name) -- default handler (optional) lspconfig[server_name].setup { - on_attach = lspstatus.on_attach, + on_attach = function(client, bufnr) + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(bufnr, true) + end + lspstatus.on_attach(client, bufnr) + end, capabilities = capabilities, } end, ["rust_analyzer"] = function() - -- require 'lazy'.load('rust-tools'); vim.cmd([[autocmd BufEnter *.rs lua require("setup.rtools")]]) end, ["clangd"] = function() diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua index 07742613..735c4b2d 100644 --- a/config/nvim/lua/plugins.lua +++ b/config/nvim/lua/plugins.lua @@ -45,7 +45,7 @@ return require('lazy').setup({ { 'rest-nvim/rest.nvim', event = "BufEnter" }, -- 'b0o/SchemaStore.nvim', -- 'rcarriga/nvim-notify', - { 'echasnovski/mini.nvim', version = '*' }, + { 'echasnovski/mini.nvim', version = '*' }, { 'folke/todo-comments.nvim', event = "BufEnter", @@ -197,16 +197,19 @@ return require('lazy').setup({ { 'norcalli/nvim-colorizer.lua', config = function() require 'colorizer'.setup() end }, { 'IndianBoy42/tree-sitter-just', - config = function() require 'tree-sitter-just'.setup({}) end, - dependencies = { - "nvim-treesitter/nvim-treesitter" }, + config = function() + require 'tree-sitter-just'.setup({}) + end, + dependencies = { "nvim-treesitter/nvim-treesitter" }, ft = "just" }, { 'LhKipp/nvim-nu', - config = function() require 'nu'.setup({ - use_lsp_features = false, - }) end, + config = function() + require 'nu'.setup({ + use_lsp_features = false, + }) + end, ft = "nu" }, -- lsp @@ -432,9 +435,17 @@ return require('lazy').setup({ -- } -- end, -- }, + -- { + -- 'simrat39/rust-tools.nvim', + -- ft = 'rust', + -- config = function() + -- require 'setup.rtools' + -- end, + -- }, { - 'simrat39/rust-tools.nvim', - ft = 'rust', + 'mrcjkb/rustaceanvim', + version = '^3', -- Recommended + ft = { 'rust' }, config = function() require 'setup.rtools' end, diff --git a/config/nvim/lua/setup/rtools.lua b/config/nvim/lua/setup/rtools.lua index 15c4dd81..e25f9617 100644 --- a/config/nvim/lua/setup/rtools.lua +++ b/config/nvim/lua/setup/rtools.lua @@ -4,247 +4,64 @@ -- local liblldb_path = extension_path .. 'lldb/lib/liblldb.dylib' local codelldb_path = '/Users/fs0c131y/.vscode-oss/extensions/vadimcn.vscode-lldb-1.8.1-universal/adapter/codelldb' local liblldb_path = '/Users/fs0c131y/.vscode-oss/extensions/vadimcn.vscode-lldb-1.8.1-universal/lldb/lib/liblldb.dylib' -local rt = require('rust-tools') local lspstatus = require('lsp-status') -- local lsp_signature = require('lsp_signature') -local opts = { - tools = { -- rust-tools options - -- automatically set inlay hints (type hints) - -- There is an issue due to which the hints are not applied on the first - -- opened file. For now, write to the file to trigger a reapplication of - -- the hints or just run :RustSetInlayHints. - -- default: true - autoSetHints = true, - - -- whether to show hover actions inside the hover window - -- this overrides the default hover handler so something like lspsaga.nvim's hover would be overriden by this - -- default: true - -- hover_with_actions = true, - - -- how to execute terminal commands - -- options right now: termopen / quickfix - executor = require("rust-tools/executors").termopen, - - -- callback to execute once rust-analyzer is done initializing the workspace - -- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" - on_initialized = nil, - - -- These apply to the default RustSetInlayHints command - inlay_hints = { - - -- Only show inlay hints for the current line - only_current_line = false, - - -- Event which triggers a refersh of the inlay hints. - -- You can make this "CursorMoved" or "CursorMoved,CursorMovedI" but - -- not that this may cause higher CPU usage. - -- This option is only respected when only_current_line and - -- autoSetHints both are true. - only_current_line_autocmd = "CursorHold", - - -- whether to show parameter hints with the inlay hints or not - -- default: true - show_parameter_hints = true, - - -- whether to show variable name before type hints with the inlay hints or not - -- default: false - show_variable_name = false, - - -- prefix for parameter hints - -- default: "<-" - parameter_hints_prefix = "<- ", - - -- prefix for all the other hints (type, chaining) - -- default: "=>" - other_hints_prefix = "=> ", - - -- whether to align to the lenght of the longest line in the file - max_len_align = false, - - -- padding from the left if max_len_align is true - max_len_align_padding = 1, - - -- whether to align to the extreme right or not - right_align = false, - - -- padding from the right if right_align is true - right_align_padding = 7, - - -- The color of the hints - highlight = "Comment", - }, - - -- options same as lsp hover / vim.lsp.util.open_floating_preview() - hover_actions = { - -- the border that is used for the hover window - -- see vim.api.nvim_open_win() - border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - }, - - -- whether the hover action window gets automatically focused - -- default: false - auto_focus = false, - }, - - -- settings for showing the crate graph based on graphviz and the dot - -- command - crate_graph = { - -- Backend used for displaying the graph - -- see: https://graphviz.org/docs/outputs/ - -- default: x11 - backend = "x11", - -- where to store the output, nil for no output stored (relative - -- path from pwd) - -- default: nil - output = nil, - -- true for all crates.io and external crates, false only the local - -- crates - -- default: true - full = true, - - -- List of backends found on: https://graphviz.org/docs/outputs/ - -- Is used for input validation and autocompletion - -- Last updated: 2021-08-26 - enabled_graphviz_backends = { - "bmp", - "cgimage", - "canon", - "dot", - "gv", - "xdot", - "xdot1.2", - "xdot1.4", - "eps", - "exr", - "fig", - "gd", - "gd2", - "gif", - "gtk", - "ico", - "cmap", - "ismap", - "imap", - "cmapx", - "imap_np", - "cmapx_np", - "jpg", - "jpeg", - "jpe", - "jp2", - "json", - "json0", - "dot_json", - "xdot_json", - "pdf", - "pic", - "pct", - "pict", - "plain", - "plain-ext", - "png", - "pov", - "ps", - "ps2", - "psd", - "sgi", - "svg", - "svgz", - "tga", - "tiff", - "tif", - "tk", - "vml", - "vmlz", - "wbmp", - "webp", - "xlib", - "x11", - }, - }, - }, - -- all the opts to send to nvim-lspconfig - -- these override the defaults set by rust-tools.nvim - -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer - server = { - -- standalone file support - -- setting it to false may improve startup time - -- cmd = { "ra-multiplex" }, - standalone = true, - settings = { - ["rust-analyzer"] = { - imports = { - enforce = true, - prefix = "self", - granularity = { - group = "module", - }, - importPrefix = "self", - prefer = { - no = { - std = true - }, - } - }, - check = { - }, - inlayHints = { - closureReturnTypeHints = { - enable = true, - } - }, - cargo = { - loadOutDirsFromCheck = true, - }, - procMacro = { - enable = true, - }, - completion = { - autoimport = { - enalbe = true, - } - }, - checkOnSave = { - command = "clippy", - -- targets = "all", - allTargets = true, - }, - }, - }, - - on_attach = function(client, bufnr) - -- Hover actions - vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) - -- Code action groups - vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) - -- lsp_signature.on_attach(client, bufnr) - lspstatus.on_attach(client) - end, - -- capabilities = lspstatus.capabilities, - capabilities = require('cmp_nvim_lsp').default_capabilities(), - - }, -- rust-analyer options - -- debugging stuff - - dap = { - -- adapter = { - -- type = "executable", - -- command = "lldb-vscode", - -- name = "rt_lldb", - -- }, - adapter = require('rust-tools.dap').get_codelldb_adapter( - codelldb_path, liblldb_path) - }, -} -- vim.cmd([[autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require('rust-tools.inlay_hints').set_inlay_hints()]]) -require('rust-tools').setup(opts) +-- require('rust-tools').setup(opts) +local bufnr = vim.api.nvim_get_current_buf() +vim.keymap.set( + "n", + "a", + function() + vim.cmd.RustLsp('codeAction') + end, + { silent = true, buffer = bufnr } +) +vim.keymap.set( + "n", + "rr", + function() + vim.cmd.RustLsp('runnables') + end, + { silent = true, buffer = bufnr } +) +vim.keymap.set( + "n", + "rd", + function() + vim.cmd.RustLsp('debuggables') + end, + { silent = true, buffer = bufnr } +) +vim.keymap.set( + "n", + "ssr", + function() + vim.cmd.RustLsp('ssr') + end, + { buffer = bufnr } +) + +vim.g.rustaceanvim = { + -- Plugin configuration + -- tools = {}, + -- LSP configuration + server = { + on_attach = function(client, bufnr) + -- you can also put keymaps in here + if client.server_capabilities.inlayHintProvider then + print("Inlay hints enabled") + vim.lsp.inlay_hint.enable(bufnr, true) + end + end, + -- settings = { + -- -- rust-analyzer language server configuration + -- ["rust-analyzer"] = {}, + -- }, + -- }, + -- -- DAP configuration + -- dap = {}, + }, +}