This plugin is an attempt to provide an easier way to configure running various build,compile toolset and package manager commands that you may require for your various project development. The goal is to streamline configuring and running external commands.
- nvim >=0.8
- LSP client
-
Do you find yourself configuring separate keymappings to run
npm
commands fornode
projects ?maven
commands for yourmaven
projects?make
commands for yourMake
based projects?cargo
commands forrust
projects?go
commands forgolang
projects? ( .. and so on ) -
Do you wish for an easier way to configure to run your commands in a split terminal buffer ? vsplit terminal buffer ? tab term buffer ? floating window ? or even in an external terminal emulator window?
This plugin takes care of that. Just install the plugin and do a basic configuration.
- Running command in external terminal:
- Running command in floating window , split and vsplit term buffer:
- packer
use { 'charlie39/OneStop.nvim', branch = 'main' }
this plugin depends on language server clients to find your project root as well as club your commands. So you need to configure the commands based on under which language server client you would use them. The assigned commands would be available only under the given LSP client.
require'onestop'.setup {
--[[ For running commands in an external terminal window, assign a table
to this key.First item should be your terminal emulator and second item
should be the emulator option for launching a command
e.g. if you use suckless terminal]]
terminal = {'st','-e' },
--[[configure the layout for the floating window as per your screen ( if the default is not good for you)]]
layout = {
style = 'minimal',
relative = 'editor',
heigth = 40,
width = 120,
border = { "⌜", "-", "⌝", "|", "⌟", "_", "⌞", "|" }
},
--[[ this plugin depends on LSP clients to find the project root_dir as well as
club your commands, when a particular LSP client is attached only the
commands assigned to them would be available.]]
lscmds = {
['jdt.ls'] = {
"mvn run",
"mvn build",
"mvn compile",
"mvn spring-boot:run",
"mvn package",
"java -jar",
"mvn dependency:resolve -Didentifier=javadoc",
"mvn dependency:sources",
},
rust_analyzer = {
"cargo build",
"cargo run",
},
sumneko_lua = {
"lua",
}
...
},
--[[the only default keymap, this for toggling the floating window ]]
map = {
['<M-i>'] = 'toggle_float',
},
}
the setup function provides the command OSRunner
. This comamand by default
launches the commands in the configured terminal [ The default is st which is
what i use, so if you
don't have st installed you must set the terminal to one that is available].
OSRunner takes three subcommands:
- fl[oat] = launches the command in a float term buffer
- sp[lit] = launches the command in a split term buffer
- vs[plit] = launches the command in vsplit term buffer
- tab[new] = launches the command in a new tab term buffer
- ext[ernal] = launches the command in the configured external terminal
you can map these to your custom key binds. e.g:
vim.keymap.set('n','<leader>C', '<cmd>OSRunner external<cr>',{noremap = true})
vim.keymap.set('n','<leader>of', '<cmd>OSRunner float<cr>',{ noremap = true})
vim.keymap.set('n','<leader>ov', '<cmd>OSRunner vsplit<cr>',{ noremap = true})
vim.keymap.set('n','<leader>os', '<cmd>OSRunner split<cr>',{ noremap = true})
vim.keymap.set('n','<leader>ot', '<cmd>OSRunner tab<cr>,{noremap = true})
...
gopls = {
"go run [File]",
"go build [File]",
"go get [File]",
}
this would prompt you to input the file.
--packer
use { 'charlie39/OneStop.nvim , branch = 'main', config = require'onestop'.setup
{ terminal = { 'alacritty','-e' }} }
use { 'charlie39/OneStop.nvim , branch = 'main', config = require'onestop'.setup
{
terminal = { 'alacritty','-e' },
lscmds = {
pyright = {
"python",
"pip install [File]",
}
}
- run [preconfigured] commands in a floating window with toggle support
- run [preconfigured] commands in a split terminal buffer
- run [preconfigured] commands in a vsplit terminal buffer
- run [preconfigured] commands in a new tab terminal buffer
- run [preconfigured] commands in an external terminal window
- add support for tmux panes
- collect as many build tools specific commands [ and other commands related to development ]
This is a tiny project that i started after comming across a few posts on reddit about how to configure running external commands. This is in pre pre [yeah two times] alpha stage. Not much testing has been done. The recommended plugin manager is packer as cited above or the manual way with git.
git clone -b main https://github.com/charlie39/OneShot.nvim
~/.local/share/nvim/site/pack/packer/start/ [adjust according to your plugin.path]
If you have problem installing with other plugin manager, feel free to open an issue.
maintaining a repository of build tool/package manager commands would be a challenge for me as i won't be able to test for all of them. Hence commnunity contributions, PRs that add new commands are welcome.
Released under GPLv3 by @charlie39.