Add autocommand to run just on :make when justfile is present and add ccls

This commit is contained in:
Fabian Schmidt 2025-02-05 16:00:57 +01:00
parent 92a6cfc071
commit 14edeb2713
2 changed files with 22 additions and 1 deletions

View File

@ -9,7 +9,7 @@ vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
vim.cmd 'command W :execute \':silent w !sudo tee % > /dev/null\' | :edit!' vim.cmd 'command W :execute \':silent w !sudo tee % > /dev/null\' | :edit!'
-- Array of file names indicating root directory. Modify to your liking. -- Array of file names indicating root directory. Modify to your liking.
local root_names = { '.git', 'Makefile' } local root_names = { '.git', 'Makefile', 'justfile' }
-- Cache to use for speed up (at cost of possibly outdated results) -- Cache to use for speed up (at cost of possibly outdated results)
local root_cache = {} local root_cache = {}
@ -35,3 +35,16 @@ end
local root_augroup = vim.api.nvim_create_augroup('MyAutoRoot', {}) local root_augroup = vim.api.nvim_create_augroup('MyAutoRoot', {})
vim.api.nvim_create_autocmd('BufEnter', { group = root_augroup, callback = set_root }) vim.api.nvim_create_autocmd('BufEnter', { group = root_augroup, callback = set_root })
local function set_makeprg()
local cwd = vim.fn.getcwd()
if vim.fn.filereadable(cwd .. '/justfile') == 1 then
vim.o.makeprg = 'just'
elseif vim.fn.filereadable(cwd .. '/Makefile') == 1 then
vim.o.makeprg = 'make'
end
end
local makeprg_augroup = vim.api.nvim_create_augroup('MyMakeprg', {})
vim.api.nvim_create_autocmd('BufEnter', { pattern = '*', group = makeprg_augroup, callback = set_makeprg, })

View File

@ -50,6 +50,10 @@ return {
{ {
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
config = true config = true
--config = function()
-- ensure_installed = { "lua_ls", "ts_ls", "gopls", "rust_analyzer", "bashls", "sqlls", "html", "cssls",
-- "tailwindcss", "phpactor", "julials", "glsl_analyzer", "wgsl_analyzer", "emmet_language_server", "zls" }
--end
}, },
{ {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
@ -152,6 +156,10 @@ return {
variables = {}, variables = {},
}, },
}) })
lspconfig.ccls.setup {
capabilities = capabilities,
on_attach = lsp_attach,
}
end end
}, },
{ {