diff --git a/init.lua b/init.lua index ed50b69d7f3..3cd9beae78f 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.o` @@ -230,6 +230,29 @@ vim.api.nvim_create_autocmd('TextYankPost', { callback = function() vim.hl.on_yank() end, }) +-- Autocommand to configure clangd for Vxxx repo +local group = vim.api.nvim_create_augroup('VxxxC++', { clear = true }) +vim.api.nvim_create_autocmd('BufEnter', { + group = group, + pattern = '*', + callback = function() + local cwd = vim.fn.getcwd() + local project_root = 'C:\\Develop\\Develop\\git\\vfamecd' + if cwd:sub(1, #project_root) == project_root then + -- Configure clangd for this specific directory + require('lspconfig').clangd.setup { + cmd = { + 'C:\\Develop\\.conan\\data\\llvm\\3.0.0+v15.0.6\\_\\_\\package\\456f15897172eef340fcbac8a70811f2beb26a93\\llvm\\bin\\clangd.exe', + '--clang-tidy', + '--log=verbose', + '--compile-commands-dir=' .. project_root, + }, + init_options = { fallbackFlags = { '-std=c++17' } }, + } + end + end, +}) + -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -351,7 +374,7 @@ require('lazy').setup({ -- `build` is used to run some command when the plugin is installed/updated. -- This is only run then, not every time Neovim starts up. - build = 'make', + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', -- `cond` is a condition used to determine whether this plugin should be -- installed and loaded. @@ -544,6 +567,34 @@ require('lazy').setup({ vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + + -- Find references for the word under your cursor. + map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + + -- Lets Switch between header/source, uses clangd functionality + vim.keymap.set('n', 'gh', ':ClangdSwitchSourceHeader', { noremap = true, silent = true, desc = '[G]oto [H]eader/Source' }) + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. map('grn', vim.lsp.buf.rename, '[R]e[n]ame') @@ -600,7 +651,7 @@ require('lazy').setup({ -- See `:help lsp-config` for information about keys and how to configure ---@type table local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, @@ -949,4 +1000,4 @@ require('lazy').setup({ }) -- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +-