From 3ba2c3f858ecb26703d3a766aa8bf0907de0062d Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Tue, 9 Apr 2024 07:59:49 +0200 Subject: [PATCH] Remove the idea about auto running cmake from file detection changes --- nvim/init.lua | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index ac9bfcd..28999d7 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,4 +1,3 @@ - local function setup_yank_highlight() -- Create a new highlight group which will be used for yank highlighting with the name "YankHighlight" vim.cmd("highlight YankHighlight guibg=#e0af68") @@ -20,40 +19,14 @@ end -- Load keymaps before loading any plugins require("keymaps") - -- change and personalize native vim settings +-- change and personalize native vim settings vim.opt = require("vim_opt") - -- Initialize Lazy package manager +-- Initialize Lazy package manager require("lazy_init") - -- Initialize plugins, add a plugin by creating a new file in the plugins dir +-- Initialize plugins, add a plugin by creating a new file in the plugins dir require("lazy").setup("plugs") -- See ":help vim.highlight.on_yank()" setup_yank_highlight() - - --- Save this code snippet for later, it is used to automatically run cmake when saving a file in a project, this way we can have an up to date compile_commands.json file for clangd. --- TODO: Make sure to only run this when clangd is being used as the language server. Additionally, find a way to make this work on projects with multiple CMakeLists.txt files, or that arent using CMake at all. --- -- Define a function to find the main.cpp and CMakeLists.txt files using fzf --- function FindMainAndCMakeLists() --- local main_cpp = vim.fn.systemlist('fzf --preview "bat {}" --query main.cpp --select-1')[1] --- local cmake_lists = vim.fn.systemlist('fzf --preview "bat {}" --query CMakeLists.txt --select-1')[1] --- return main_cpp, cmake_lists --- end --- --- -- Function to update the autocmd based on the found main.cpp and CMakeLists.txt files --- function UpdateAutocmd(main_cpp_path, cmake_lists_path) --- if main_cpp_path ~= '' and cmake_lists_path ~= '' then --- local main_cpp_directory = vim.fn.fnamemodify(main_cpp_path, ':h') --- vim.api.nvim_exec(string.format([[ --- autocmd! BufWritePost %s/**/* :call system('cmake %s') --- ]], main_cpp_directory, cmake_lists_path), false) --- else --- print("main.cpp or CMakeLists.txt not found. Autocmd not updated.") --- end --- end --- --- -- Automatically find main.cpp and CMakeLists.txt and set up the initial autocmd --- local main_cpp_path, cmake_lists_path = FindMainAndCMakeLists() --- UpdateAutocmd(main_cpp_path, cmake_lists_path)