Get filetype of REPL #377
Replies: 2 comments 2 replies
-
I stumbled over the same topic, because I was confused about hide repl giving errors if on the repl. I think one can enhance this in the plugin itself and maybe will create a pull request. If you want to do this for own mappings, you can require iron.lowlevel and get the store. There you have the configs for the different repls. You can iterate over them and check if the buffer matches your current buffer. If so you can grap the key of that config and have the filetype associated with that repl. Thst is written down in iron.lowlevel.get_repl_ft_for_bufnr |
Beta Was this translation helpful? Give feedback.
-
You can set in the {
config = {
repl_open_cmd = function(bufnr)
-- iron doesn't set the filetype for the buffers it creates so we need
-- to provide one.
vim.api.nvim_set_option_value("filetype", "iron", { buf = bufnr })
-- Create a window and return it's id.
return require("iron.view").split.vertical.botright(40)(bufnr)
end,
}
} @rwijtvliet You could combine this with function @frere-jacques suggested and create the filetype based on |
Beta Was this translation helpful? Give feedback.
-
I'd like to write keymaps that work both in the buffer with the source code and in the buffer with the REPL terminal.
For example,
<leader>rf
should focus the REPL - regardless of where the cursor is currently located. (a) If it's in the code buffer, it should (if needed) make the REPL visible and move the cursor there, and (b) if it's already in the REPL buffer, nothing should happen.These do not work in situation (b) (
Executing Lua callback: ...t/.local/share/nvim/lazy/iron.nvim/lua/iron/lowlevel.lua:39: Empty filetype
):Same when trying to hide the REPL window with
IronHide
oriron.hide_repl
.--> Is there a way, a lua function, that I can use to find the filetype of the REPL buffer?
Beta Was this translation helpful? Give feedback.
All reactions