Always make :Build/:BuildDir available

Don't attached this functionality to only c/cpp filetypes.
This commit is contained in:
Kenneth Benzie 2024-03-18 20:02:54 +00:00
parent 0c1328ead4
commit 831ac41440
3 changed files with 13 additions and 18 deletions

View File

@ -1 +0,0 @@
require('build').create_commands()

View File

@ -1,4 +1,2 @@
vim.opt.commentstring = '//%s'
vim.opt.matchpairs:append('<:>')
require('build').create_commands()

View File

@ -151,22 +151,20 @@ function build.list_targets()
return targets
end
function build.create_commands()
local buffer = vim.api.nvim_get_current_buf()
local buffer = vim.api.nvim_get_current_buf()
-- Create :BuildDir command
vim.api.nvim_buf_create_user_command(buffer, 'BuildDir', function(opts)
build.set_dir(opts.fargs[1])
end, {
bang = true, nargs = '?', complete = build.list_dirs,
})
-- Create :BuildDir command
vim.api.nvim_buf_create_user_command(buffer, 'BuildDir', function(opts)
build.set_dir(opts.fargs[1])
end, {
bang = true, nargs = '?', complete = build.list_dirs,
})
-- Create :Build command
vim.api.nvim_buf_create_user_command(buffer, 'Build', function(opts)
build.run(opts.fargs)
end, {
bang = true, nargs = '*', complete = build.list_targets,
})
end
-- Create :Build command
vim.api.nvim_buf_create_user_command(buffer, 'Build', function(opts)
build.run(opts.fargs)
end, {
bang = true, nargs = '*', complete = build.list_targets,
})
return build