From 6edcafeafc1531808f26b0098bdbad3b0d32917e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis=20=C5=BDaltauskas?= <34091448+akaZX@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:25:05 +0200 Subject: [PATCH 1/2] Updated config for C++ development --- init.lua | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 4ce35f4b5c4..2a2aaccc65a 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ ---[[ +[ ===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== @@ -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.opt` @@ -204,6 +204,29 @@ vim.api.nvim_create_autocmd('TextYankPost', { 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' @@ -343,7 +366,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. @@ -518,6 +541,9 @@ require('lazy').setup({ -- 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') @@ -614,7 +640,7 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, From e705f2a37305c4bf54ed2d3eaab0fe69655bc0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis=20=C5=BDaltauskas?= <34091448+akaZX@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:26:10 +0200 Subject: [PATCH 2/2] Update init.lua --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 2a2aaccc65a..2c1eec97c77 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -[ +--[[ ===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== @@ -992,4 +992,4 @@ require('lazy').setup({ }) -- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +-