move around file_specifc configuration to a easy to modify table instead
This commit is contained in:
+23
-12
@@ -84,7 +84,27 @@ local function has_makefile()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set makeprg
|
-- FILE SPECIFIC AND AUTOCMDS {{{1
|
||||||
|
local file_specific = {
|
||||||
|
lua = function ()
|
||||||
|
end,
|
||||||
|
go = function()
|
||||||
|
vim.bo.makeprg = 'go'
|
||||||
|
end,
|
||||||
|
c = function()
|
||||||
|
if not has_makefile() then
|
||||||
|
vim.bo.makeprg = 'tcc -run %'
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
python = function()
|
||||||
|
vim.bo.makeprg = 'basedpyright'
|
||||||
|
end,
|
||||||
|
swift = function()
|
||||||
|
vim.bo.makeprg = 'swift'
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
-- buffer specifc config
|
||||||
vim.api.nvim_create_autocmd('BufEnter', {
|
vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
callback = function()
|
callback = function()
|
||||||
do
|
do
|
||||||
@@ -97,17 +117,8 @@ vim.api.nvim_create_autocmd('BufEnter', {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if vim.bo.filetype == 'go' then
|
local conf = file_specific[vim.bo.filetype]
|
||||||
vim.bo.makeprg = 'go'
|
if conf then conf() end
|
||||||
elseif vim.bo.filetype == 'c' then
|
|
||||||
if not has_makefile() then
|
|
||||||
vim.bo.makeprg = 'tcc -run %'
|
|
||||||
end
|
|
||||||
elseif vim.bo.filetype == 'python' then
|
|
||||||
vim.bo.makeprg = 'basedpyright'
|
|
||||||
elseif vim.bo.filetype == 'swift' then
|
|
||||||
vim.bo.makeprg = 'swift'
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user