Add autocommand to run just on :make when justfile is present and add ccls
This commit is contained in:
parent
92a6cfc071
commit
14edeb2713
@ -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!'
|
||||
|
||||
-- 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)
|
||||
local root_cache = {}
|
||||
@ -35,3 +35,16 @@ end
|
||||
|
||||
local root_augroup = vim.api.nvim_create_augroup('MyAutoRoot', {})
|
||||
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, })
|
||||
|
@ -50,6 +50,10 @@ return {
|
||||
{
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
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',
|
||||
@ -152,6 +156,10 @@ return {
|
||||
variables = {},
|
||||
},
|
||||
})
|
||||
lspconfig.ccls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = lsp_attach,
|
||||
}
|
||||
end
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user