From 0db7f3a9c20c7b414fb3da3fd70e12dc8af77e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Kmie=C4=87?= Date: Tue, 8 Aug 2023 10:04:36 +0200 Subject: [PATCH] Nvim: update clangd_extensions with new config format --- .config/nvim/lua/plugins/init.lua | 12 ++- .config/nvim/lua/plugins/lspconfig.lua | 112 ++++++++++++++++++++---- .config/nvim/lua/plugins/treesitter.lua | 2 +- 3 files changed, 99 insertions(+), 27 deletions(-) diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index c207c59..7d398e5 100644 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -3,10 +3,7 @@ return {{ --"vim-test/vim-test", --"RRethy/vim-illuminate", { "ftilde/vim-ugdb", cmd = "UGDBBreakpoint" }, -"jubnzv/virtual-types.nvim", -'p00f/clangd_extensions.nvim', -'ray-x/lsp_signature.nvim', -"mrjones2014/nvim-ts-rainbow", +"HiPhish/nvim-ts-rainbow2", -- }}} -- }}} @@ -16,7 +13,6 @@ return {{ "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "nvim-lua/popup.nvim", -"stevearc/dressing.nvim", "wellle/targets.vim", -- }}} @@ -30,7 +26,10 @@ return {{ --"vim-pandoc/vim-pandoc", --"weirongxu/plantuml-previewer.vim", | "aklt/plantuml-syntax", -"kergoth/vim-bitbake", -- Bitbake templates and syntax +{ + "kergoth/vim-bitbake", -- Bitbake templates and syntax + ft = { "bitbake" } +}, -- }}} -- Other plugins (external tools, etc) {{{ @@ -70,7 +69,6 @@ return {{ --require('lsp_lines').setup() --"mfussenegger/nvim-dap", ---"nguyenvukhang/nvim-toggler", --"rgroli/other.nvim", " Currently doesn't support C/C++ --"smolovk/projector.nvim", "Pocco81/true-zen.nvim", diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 27c94ef..04da9b1 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -1,7 +1,10 @@ return { 'neovim/nvim-lspconfig', - requires = { + dependencies = { "SmiteshP/nvim-navbuddy", + {url = "http://git.sr.ht/~p00f/clangd_extensions.nvim"}, + "jubnzv/virtual-types.nvim", + "ray-x/lsp_signature.nvim", }, config = function() local nvim_lsp = require('lspconfig') @@ -47,6 +50,8 @@ return { }) require'nvim-navbuddy'.attach(client, bufnr) require'nvim-navic'.attach(client, bufnr) + require("clangd_extensions.inlay_hints").setup_autocmd() + require("clangd_extensions.inlay_hints").set_inlay_hints() end local signs = { @@ -107,25 +112,94 @@ return { -- ) -- ) - clangd_extensions.setup({ - server = { - on_attach = on_attach, - root_pattern = { - '.clangd', - '.clang-tidy', - '.clang-format', - 'compile_commands.json', - 'compile_flags.txt', - 'configure.ac', - }, - capabilities = capabilities + nvim_lsp.clangd.setup({ + settings = { + inlay_hints = { + inline = vim.fn.has("nvim-0.10") == 1, + -- Options other than `highlight' and `priority' only work + -- if `inline' is disabled + -- Only show inlay hints for the current line + only_current_line = false, + -- Event which triggers a refresh 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 + show_parameter_hints = true, + -- prefix for parameter hints + parameter_hints_prefix = "<- ", + -- prefix for all the other hints (type, chaining) + other_hints_prefix = "=> ", + -- whether to align to the length 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", + -- The highlight group priority for extmark + priority = 100, }, - inlay_hints = { - inline = false, - max_len_align = true, - max_len_align_padding = 3, - right_align = true, - } + ast = { + -- These are unicode, should be available in any font + role_icons = { + type = "🄣", + declaration = "🄓", + expression = "🄔", + statement = ";", + specifier = "🄱", + ["template argument"] = "🆃", + }, + kind_icons = { + Compound = "đŸ„Č", + Recovery = "🅁", + TranslationUnit = "🅄", + PackExpansion = "🄿", + TemplateTypeParm = "🅃", + TemplateTemplateParm = "🅃", + TemplateParamObject = "🅃", + }, + --[[ These require codicons (https://github.com/microsoft/vscode-codicons) + role_icons = { + type = "î­Ł", + declaration = "îȘŒ", + expression = "", + specifier = "", + statement = "îȘ†", + ["template argument"] = "îȘ’", + }, + + kind_icons = { + Compound = "îȘ‹", + Recovery = "îȘ‡", + TranslationUnit = "î«©", + PackExpansion = "", + TemplateTypeParm = "îȘ’", + TemplateTemplateParm = "îȘ’", + TemplateParamObject = "îȘ’", + }, ]] + highlights = { + detail = "Comment", + }, + memory_usage = { + border = "none", + }, + symbol_info = { + border = "none", + } + } + }, + on_attach = on_attach, + --on_publish_diagnostics = diagnostic_handler, + capabilities = capabilities, + -- flags = { + -- debounce_text_changes = 150, + -- } }) nvim_lsp.pylsp.setup({ diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index fb4ac06..929abec 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -97,6 +97,6 @@ return { }, } vim.opt.foldmethod = "expr" - -- vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + vim.opt.foldexpr = "nvim_treesitter#foldexpr()" end }