Replies: 2 comments
-
This could be done in index 781f5f4..c68b282 100644
--- a/lua/rust-tools/executors/termopen.lua
+++ b/lua/rust-tools/executors/termopen.lua
@@ -16,6 +16,7 @@ function M.execute_command(command, args, cwd)
-- create the new buffer
latest_buf_id = vim.api.nvim_create_buf(false, true)
+ vim.bo[latest_buf_id].filetype = 'rustrunnable'
-- split the window to create a new buffer and set it to our window
utils.split(false, latest_buf_id) There is also a toggleterm implementation in there, but honestly I'm not sure if/how it gets used. Toggleterm sets its own filetype to |
Beta Was this translation helpful? Give feedback.
-
Honestly, looking at it a bit more, you should probably plan for things to not have a filetype. I think it'll be quite common that buffers that are not files are going to be missing it. You could hack around it with something like: vim.api.nvim_create_autocmd('TermOpen', {
callback = function(args)
if vim.bo[args.buf].filetype == '' then
vim.api.nvim_buf_set_option(args.buf, 'filetype', 'terminal')
end
end
}) Or if you really want it for this specific thing, something like this will work. There's nothing uniquely identifiable other than the fact that (at least currently), all of the commands fired here will contain vim.api.nvim_create_autocmd('TermOpen', {
pattern = '*&& cargo*',
callback = function(args)
if vim.bo[args.buf].filetype == '' then
vim.api.nvim_buf_set_option(args.buf, 'filetype', 'rustrunnable')
end
end
}) |
Beta Was this translation helpful? Give feedback.
-
When I press :RustRun, it opens up debug window, but it does not have a filetype, which cause a bit of problem for status line display and other operations I may hook to a filetype.
My question is, can you set a filetype for it? or is there anyway I can set a filetype detection for it.
Beta Was this translation helpful? Give feedback.
All reactions