The Trunk Check Neovim Plugin is in Beta with limited support. If you encounter any issues, feel free to reach out to us on Slack or make a PR directory. For more information, see CONTRIBUTING.
Trunk Check runs 100+ tools to format, lint, static-analyze, and security-check dozens of languages and config formats. It will autodetect the best tools to run for your repo, then run them and provide results inline in Neovim. Compare to the Trunk Check VSCode Extension. The Neovim plugin has the following capabilities:
neovim-trunk
can be installed using your favorite Neovim plugin manager. We've included some
instructions below:
Note: Some plugin managers offer varying capabilities for configuration and pinning refs
v0.9.2
1.17.0
sed
and tee
to be in PATH
timeout
is in PATH
lua/init.lua
file (on UNIX ~/.config/nvim/lua/init.lua
)lua require("init")
to your init.vim
file (on UNIX ~/.config/nvim/init.vim
)lua/init.lua
file:require("lazy").setup({
{
"trunk-io/neovim-trunk",
lazy = false,
-- optionally pin the version
-- tag = "v0.1.1",
-- these are optional config arguments (defaults shown)
config = {
-- trunkPath = "trunk",
-- lspArgs = {},
-- formatOnSave = true,
-- formatOnSaveTimeout = 10, -- seconds
-- logLevel = "info"
},
main = "trunk",
dependencies = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"}
}
})
init.vim
file (on UNIX ~/.config/nvim/init.vim
)call plug#begin()
" Required dependencies
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'trunk-io/neovim-trunk', { 'tag': '*' }
call plug#end()
lua if not pcall(function() require'trunk'.setup({}) end) then print("Run :PlugInstall and then relaunch Neovim to setup Trunk") end
setup
command as desired.:PlugInstall
to install and :PlugStatus
to verifylua/plugins.lua
file (on UNIX ~/.config/nvim/lua/plugins.lua
).lua require("plugins")
to your init.vim file (on UNIX ~/.config/nvim/init.vim
)lua/plugins.lua
file:return require("packer").startup(function(use)
use {
"trunk-io/neovim-trunk",
tag = "*",
requires = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"},
-- these are optional config arguments (defaults shown)
config = function() require("trunk").setup({
-- trunkPath = "trunk",
-- formatOnSave = true,
-- lspArgs = {},
-- formatOnSaveTimeout = 10, -- seconds
-- logLevel = "info"
}) end
}
end)
:PackerSync
to install and :PackerStatus
to verifylua/init.lua
(on UNIX ~/.config/nvim/lua/init.lua
) file:require "paq" {
-- Required dependencies
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
"trunk-io/neovim-trunk"
}
if not pcall(function() require'trunk'.setup({}) end) then
print("Run :PaqInstall and then relaunch Neovim to setup Trunk")
end
setup
command as desired.lua require("init")
to your init.vim
file (on UNIX ~/.config/nvim/init.vim
):PaqInstall
trunk init
in
your reponvim <file>
:lua vim.lsp.buf.code_action()
on a highlighted section to view and apply autofixes:w
) to autoformat the
fileOther commands:
:TrunkConfig
to open the repo .trunk/trunk.yaml
file for editing:TrunkStatus
to review any linter failures:TrunkQuery
to view the list of linters that run on your current file:TrunkActions
to view any Trunk Actions that have generated notifications and run their
commands as appropriateThe neovim extension can be configured as follows:
Option | Configures | Default |
---|---|---|
trunkPath | Where to find the Trunk CLI launcher of binary | "trunk" |
lspArgs | Optional arguments to append the Trunk LSP Server | {} |
formatOnSave | Whether or not to autoformat file buffers when written | true |
formatOnSaveTimeout | The maximum amount of time to spend attempting to autoformat, in seconds | 10 |
logLevel | Verbosity of logs from the Neovim extension | "info" |
(These settings can be changed after loading by calling require("neovim-trunk").setup({})
)
Unlike for VSCode, the Trunk Check Neovim Plugin does not currently provide any summary views for diagnostics. If you'd like, you can use a plugin like Trouble to view aggregate code actions.
Please view our docs for any additional Trunk setup instructions, as well as our plugins repo for the up to date list of supported linters.
When lint diagnostics show up, they may cause the line number column increase in width. To fix this,
run :set signcolumn=yes
to have a column for diagnostics always present.