vim-replant icon indicating copy to clipboard operation
vim-replant copied to clipboard

Add support for Vim8

Open eraserhd opened this issue 7 years ago • 8 comments

"profiles.clj" [New File]
Error detected while processing function replant#insert_ns_definition_maybe[3]..replant#ui#expected_ns:
line    1:
E117: Unknown function: nvim_get_current_buf
E15: Invalid expression: a:000 is 1 ? a:1 : nvim_get_current_buf()
Press ENTER or type command to continue

eraserhd avatar Apr 16 '18 16:04 eraserhd

Makes sense, I haven't put any effort into supporting vim8. I think this is the automatic (ns) insertion feature.

I'm not sure that the plugin will work, generally, with vim8, I haven't tested. Maybe it would with https://github.com/roxma/vim-hug-neovim-rpc or similar.

This could potentially be rewritten to not use the nvim_ functions, but I'm reluctant to where the resultant code is otherwise confusing/complicated.

SevereOverfl0w avatar Apr 16 '18 17:04 SevereOverfl0w

replant#ui#expected_ns() looks like a re-implementation of fireplace#ns(), maybe use that instead? It won't fix everything but it will at least let you have the plugin installed without constantly getting yelled at.

Edit: Use the newly tweaked fireplace#platform().BufferNs() if you don't want to deal with user.

  let platform = fireplace#platform()
  return call(platform.BufferNs, a:000, platform)

tpope avatar Jul 29 '19 18:07 tpope

Adding the namespace also doesn't play nice if another template is applied first (from salve.vim for example). Consider clearing the buffer with silent %delete _ first.

tpope avatar Jul 29 '19 18:07 tpope

One of the issues I previously had (and I'm not sure I fixed it with my impl - but was an eventual goal) was that :p wasn't reliably finding a repl for me due to it not working in new directories (e.g. :e src/newdir/foo.clj couldn't find an nrepl).

This is more obvious for this particular task.

I'll have a go at porting this over to fireplace#ns(), as I know there's bugs in my implementation anyway.

SevereOverfl0w avatar Aug 03 '19 06:08 SevereOverfl0w

I really recommend against editing a file before creating a directory - Vim does not like it when you do that - but I think it would be okay to tweak fireplace#ns() to do what you mean in this case. The key is to prepend getcwd() but guard against both absolute paths and both real and pseudo URLs http://localhost but also zipfile:whatever.zip::file.txt. Something like path !~# '^/\|^\a\+: should do the trick.

tpope avatar Aug 03 '19 16:08 tpope

As often happens, deciding what needs to be done means I went ahead and did it. This also means I had to automatically connect based on that busted buffer name which is a bit discomforting but I guess we'll see if anything breaks.

tpope avatar Aug 03 '19 18:08 tpope

If there's no repl running then replant#ns() returns 'user'. I think there's a few subtle differences where fireplace#ns is intending something different than what the expected ns would be based on the classpath.

I think this functionality has overlap with salve.vim.

SevereOverfl0w avatar Aug 15 '19 06:08 SevereOverfl0w

I would blacklist user, or use fireplace#platform().BufferNs() to get a version with a blank string instead.

tpope avatar Aug 15 '19 07:08 tpope