Add autocommand to run just on :make when justfile is present and add ccls
This commit is contained in:
@@ -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, })
|
||||
|
Reference in New Issue
Block a user