Created
April 4, 2024 08:34
-
-
Save pashu123/7369b86bd0cb344a5b3be34969afb2e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Read the docs: https://www.lunarvim.org/docs/configuration | |
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6 | |
-- Forum: https://www.reddit.com/r/lunarvim/ | |
-- Discord: https://discord.com/invite/Xb9B4Ny | |
-- | |
lvim.colorscheme = "lunar" | |
lvim.format_on_save.enabled = false | |
local formatters = require("lvim.lsp.null-ls.formatters") | |
formatters.setup({ | |
{ command = "black", filetypes = { "python" } }, | |
-- other formatters for other languages go in this list | |
}) | |
vim.opt_local.wrap = true | |
vim.api.nvim_set_keymap('n', '<leader>lf', '<cmd>lua vim.lsp.buf.format()<CR>', { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>vrn', '<cmd>lua vim.lsp.buf.rename()<CR>', { noremap = true, silent = true }) | |
vim.g.editorconfig = false | |
lvim.builtin.telescope.pickers.buffers.sort_mru = true | |
lvim.builtin.telescope.pickers.buffers.ignore_current_buffer = true | |
vim.keymap.set("n", "<leader>vs", "<cmd>Telescope current_buffer_fuzzy_find<cr>") | |
table.insert(lvim.plugins, { | |
"zbirenbaum/copilot-cmp", | |
event = "InsertEnter", | |
dependencies = { "zbirenbaum/copilot.lua" }, | |
config = function() | |
vim.defer_fn(function() | |
require("copilot").setup() -- https://github.com/zbirenbaum/copilot.lua/blob/master/README.md#setup-and-configuration | |
require("copilot_cmp").setup() -- https://github.com/zbirenbaum/copilot-cmp/blob/master/README.md#configuration | |
end, 100) | |
end, | |
}) | |
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" }) | |
-- some settings can only passed as commandline flags, see `clangd --help` | |
local clangd_flags = { | |
"--background-index", | |
"--fallback-style=Google", | |
"--all-scopes-completion", | |
"--clang-tidy", | |
"--log=error", | |
"--suggest-missing-includes", | |
"--cross-file-rename", | |
"--completion-style=detailed", | |
"--pch-storage=memory", -- could also be disk | |
"--folding-ranges", | |
"--enable-config", -- clangd 11+ supports reading from .clangd configuration file | |
"--offset-encoding=utf-16", --temporary fix for null-ls | |
-- "--limit-references=1000", | |
-- "--limit-resutls=1000", | |
-- "--malloc-trim", | |
-- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type", | |
-- "--header-insertion=never", | |
-- "--query-driver=<list-of-white-listed-complers>" | |
} | |
local provider = "clangd" | |
local custom_on_attach = function(client, bufnr) | |
require("lvim.lsp").common_on_attach(client, bufnr) | |
local opts = { noremap = true, silent = true, buffer = bufnr } | |
vim.keymap.set("n", "<leader>lh", "<cmd>ClangdSwitchSourceHeader<cr>", opts) | |
vim.keymap.set("x", "<leader>lA", "<cmd>ClangdAST<cr>", opts) | |
vim.keymap.set("n", "<leader>lH", "<cmd>ClangdTypeHierarchy<cr>", opts) | |
vim.keymap.set("n", "<leader>lt", "<cmd>ClangdSymbolInfo<cr>", opts) | |
vim.keymap.set("n", "<leader>lm", "<cmd>ClangdMemoryUsage<cr>", opts) | |
require("clangd_extensions.inlay_hints").setup_autocmd() | |
require("clangd_extensions.inlay_hints").set_inlay_hints() | |
end | |
local status_ok, project_config = pcall(require, "rhel.clangd_wrl") | |
if status_ok then | |
clangd_flags = vim.tbl_deep_extend("keep", project_config, clangd_flags) | |
end | |
local custom_on_init = function(client, bufnr) | |
require("lvim.lsp").common_on_init(client, bufnr) | |
require("clangd_extensions.config").setup {} | |
require("clangd_extensions.ast").init() | |
vim.cmd [[ | |
command ClangdToggleInlayHints lua require('clangd_extensions.inlay_hints').toggle_inlay_hints() | |
command -range ClangdAST lua require('clangd_extensions.ast').display_ast(<line1>, <line2>) | |
command ClangdTypeHierarchy lua require('clangd_extensions.type_hierarchy').show_hierarchy() | |
command ClangdSymbolInfo lua require('clangd_extensions.symbol_info').show_symbol_info() | |
command -nargs=? -complete=customlist,s:memuse_compl ClangdMemoryUsage lua require('clangd_extensions.memory_usage').show_memory_usage('<args>' == 'expand_preamble') | |
]] | |
end | |
local opts = { | |
cmd = { provider, unpack(clangd_flags) }, | |
on_attach = custom_on_attach, | |
on_init = custom_on_init, | |
} | |
require("lvim.lsp.manager").setup("clangd", opts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment