From 831ac414408f30f774e3052004c82f80223fc59f Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 18 Mar 2024 20:02:54 +0000 Subject: [PATCH] Always make :Build/:BuildDir available Don't attached this functionality to only c/cpp filetypes. --- after/ftplugin/c.lua | 1 - after/ftplugin/cpp.lua | 2 -- lua/build.lua | 28 +++++++++++++--------------- 3 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 after/ftplugin/c.lua diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua deleted file mode 100644 index cd1cc3b..0000000 --- a/after/ftplugin/c.lua +++ /dev/null @@ -1 +0,0 @@ -require('build').create_commands() diff --git a/after/ftplugin/cpp.lua b/after/ftplugin/cpp.lua index ebe79e5..15e2cfd 100644 --- a/after/ftplugin/cpp.lua +++ b/after/ftplugin/cpp.lua @@ -1,4 +1,2 @@ vim.opt.commentstring = '//%s' vim.opt.matchpairs:append('<:>') - -require('build').create_commands() diff --git a/lua/build.lua b/lua/build.lua index 5565395..fa4ed92 100644 --- a/lua/build.lua +++ b/lua/build.lua @@ -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