R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
155 stars 16 forks source link

`assign_map` should be disabled differently #47

Closed wklimowicz closed 7 months ago

wklimowicz commented 7 months ago

Well done on the refactoring!

Either the documentation or implementation on assign_map is incorrect. Setting

assign_map = ""

Leads to an error on opening an R file. I don't know enough lua to edit the implementation, but I got it to work by doing:

assign_map = "<Nop>"

This might not be 100% correct. The documentation in question:

https://github.com/R-nvim/R.nvim/blob/79db76a753519c36df531ff69e3de7ad3ddc28b8/doc/R.nvim.txt#L945-L948

Error Message ``` Error detected while processing BufReadPost Autocommands for "*": Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:30: Error executing lua: /usr/share/nvim/runtime/filetype.lua: 31: BufReadPost Autocommands for "*"..FileType Autocommands for "*"..function 1_LoadFTPlugin[20]..script /home/wojtek/.local /share/nvim/lazy/R.nvim/ftplugin/r_rnvim.lua: Vim(runtime):E5113: Error while calling lua chunk: /home/wojtek/.local/share/nvim/l azy/R.nvim/lua/r/maps.lua:197: Invalid (empty) LHS stack traceback: [C]: in function 'nvim_buf_set_keymap' /home/wojtek/.local/share/nvim/lazy/R.nvim/lua/r/maps.lua:197: in function 'edit' /home/wojtek/.local/share/nvim/lazy/R.nvim/lua/r/maps.lua:291: in function 'create' ...ojtek/.local/share/nvim/lazy/R.nvim/ftplugin/r_rnvim.lua:61: in main chunk [C]: in function 'nvim_cmd' /usr/share/nvim/runtime/filetype.lua:31: in function [C]: in function 'nvim_buf_call' /usr/share/nvim/runtime/filetype.lua:30: in function stack traceback: [C]: in function 'nvim_cmd' /usr/share/nvim/runtime/filetype.lua:31: in function [C]: in function 'nvim_buf_call' /usr/share/nvim/runtime/filetype.lua:30: in function stack traceback: [C]: in function 'nvim_buf_call' /usr/share/nvim/runtime/filetype.lua:30: in function ```
jalvesaq commented 7 months ago

Thanks for reporting the issue! I will fix the documentation.

maitra commented 7 months ago

In ESS, _ converts to <- (the assignment operator) while using _ in quick succession (i.e. __) switches it back to _. This is a throwback to the old days (before R 1.6) when _ was allowed as an assignment operator. Is is possible to get this behaviour with nvim-R?

jalvesaq commented 7 months ago

Yes, it's possible, but Nvim-R's function ReplaceUnderS() has to be converted to Lua. Then, if the assign_map were _, we would run replace_underscore() instead of assign(). Can you open an issue for this, please? If nobody converts it, I can do it in a few days.