Giter Club home page Giter Club logo

Comments (19)

Olical avatar Olical commented on May 14, 2024 2

Well that's weird... definitely some strange path things going on here but glad the hunch was essentially correct. I think different functions in nvim are reporting different paths depending on your dir being in a symlink or not 😬

But yay! It's fixed! Thank you for your thanks, there's a lot more to do before I'm relatively happy, I hope you get a lot of value out of my work πŸ˜„

Success

from conjure.

Olical avatar Olical commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

I am informed by the OSX dev to my right that it does have a /tmp, so it's probably not the /tmp/conjure.cljc buffer not being created. I would guess it's a setting in Neovim like "new lines at end of empty files" or something so the line count is reporting nil instead of 0.

Your logs will prove this though, every RPC call gets written there when it's enabled so we'll see what Conjure asked and what it got back from Neovim πŸ˜ƒ should be an easy fix.

from conjure.

scotts777 avatar scotts777 commented on May 14, 2024

I really appreciate you taking the time to look into this. Yes the /tmp exists and I can see the buffer in the split.
NVIM v0.3.4
Build type: Release
LuaJIT 2.0.5

Here is the log output.

INFO [conjure.dev:17] - Logging initialised
INFO [conjure.rpc:132] - Starting RPC loops
TRACE [conjure.rpc:162] - Received RPC message: {:type :notify, :method :add, :params ["{:tag :dev, :port 40404}"]}
INFO [conjure.prepl:110] - Adding :dev 127.0.0.1 40404
TRACE [conjure.rpc:151] - Sending RPC message: {:type :request, :id 1, :method :nvim-execute-lua, :params ["return require('conjure').upsert_log(...)" ("/tmp/conjure.cljc" 40 false false)]}
TRACE [conjure.rpc:120] - Sent request, awaiting response: {:type :request, :id 1, :method :nvim-execute-lua, :params ["return require('conjure').upsert_log(...)" ("/tmp/conjure.cljc" 40 false false)]}
TRACE [conjure.rpc:154] - Sent!
TRACE [conjure.rpc:162] - Received RPC message: {:type :response, :id 1, :error nil, :result nil}
TRACE [conjure.rpc:26] - Received response: {:type :response, :id 1, :error nil, :result nil}
TRACE [conjure.rpc:120] - Sent request, awaiting response: {:type :request, :id 1, :method :nvim-buf-line-count, :params [nil]}
TRACE [conjure.rpc:151] - Sending RPC message: {:type :request, :id 1, :method :nvim-buf-line-count, :params [nil]}
TRACE [conjure.rpc:154] - Sent!
TRACE [conjure.rpc:162] - Received RPC message: {:type :response, :id 1, :error [0 "Wrong type for argument 1, expecting Buffer"], :result nil}
TRACE [conjure.rpc:26] - Received response: {:type :response, :id 1, :error [0 "Wrong type for argument 1, expecting Buffer"], :result nil}
ERROR [conjure.nvim:12] - Error while making nvim call {:method :nvim-buf-line-count, :params [nil]} -> {:error [0 "Wrong type for argument 1, expecting Buffer"], :result nil}
ERROR [conjure.rpc:?] - Error from thread 'RPC message handler': java.lang.NullPointerException

from conjure.

Olical avatar Olical commented on May 14, 2024

Not a problem! You're helping me make a better tool by reporting it!

Received RPC message: {:type :response, :id 1, :error [0 "Wrong type for argument 1, expecting Buffer"], :result nil}

Hmm, that'll be the one. So I wonder why the buffer is nil, that should be the reference to the log buffer that comes back from the Lua code. A bit convoluted I know, but I have my reasons πŸ˜…

from conjure.

scotts777 avatar scotts777 commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

This means that one of these is returning nil when it should be returning the buffer ID:

conjure/lua/conjure.lua

Lines 3 to 49 in 68c2dac

-- Find the log window and buffer if they exist.
local function find_log (log_buf_name)
local tabpage = vim.api.nvim_get_current_tabpage()
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
for _, win in ipairs(wins) do
local buf = vim.api.nvim_win_get_buf(win)
local buf_name = vim.api.nvim_buf_get_name(buf)
if buf_name == log_buf_name then
return {win = win, buf = buf}
end
end
return nil
end
-- Find or create (and then find again) the log window and buffer.
function conjure.upsert_log (log_buf_name, width, focus, resize)
local result = find_log(log_buf_name)
if result then
if focus == true then
vim.api.nvim_set_current_win(result.win)
end
if resize == true then
vim.api.nvim_win_set_width(result.win, width)
end
return result
else
vim.api.nvim_command("botright " .. width .. "vsplit " .. log_buf_name)
vim.api.nvim_command("setlocal winfixwidth")
vim.api.nvim_command("setlocal buftype=nofile")
vim.api.nvim_command("setlocal bufhidden=hide")
vim.api.nvim_command("setlocal nowrap")
vim.api.nvim_command("setlocal noswapfile")
vim.api.nvim_command("setlocal nobuflisted")
vim.api.nvim_command("setlocal nospell")
if focus ~= true then
vim.api.nvim_command("wincmd p")
end
return find_log(log_buf_name)
end
end

And you won't see it in the buffer list, it's a special hidden thing that can't be accidentally written to a file or clutter your buffer list etc. As long as you can see the window with the buffer name set to /tmp/conjure.cljc that's enough proof for me.

So why the nil... I do wonder if it could be some sort of race condition that isn't present on my machine.

from conjure.

Olical avatar Olical commented on May 14, 2024

Is there anything else interesting / scaring in :messages? Like possibly related to these commands?

conjure/lua/conjure.lua

Lines 34 to 41 in 68c2dac

vim.api.nvim_command("botright " .. width .. "vsplit " .. log_buf_name)
vim.api.nvim_command("setlocal winfixwidth")
vim.api.nvim_command("setlocal buftype=nofile")
vim.api.nvim_command("setlocal bufhidden=hide")
vim.api.nvim_command("setlocal nowrap")
vim.api.nvim_command("setlocal noswapfile")
vim.api.nvim_command("setlocal nobuflisted")
vim.api.nvim_command("setlocal nospell")

I wonder if one of those could be failing and causing the Lua function to return nil after mostly creating the buffer.

from conjure.

scotts777 avatar scotts777 commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

Just out of interest, swapping your vim-plug call to 'commit': 'ecfb1c09e5e8258036dfb30f3927e33488533e98' doesn't help, right? I just fixed the requiring of Compliment if you don't have it in your project.

from conjure.

scotts777 avatar scotts777 commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

Okay, I'm out of lunch time now but will have a look ASAP. Just need to try and repo which seems hard 😬 I'd be surprised if it was OSX specific but maybe! Do you have other plugins / settings or is it a blank neovim? I might try to repro it in a bare bones neovim environment.

Latest commit is better too, prints out the full stack trace when something goes wrong 063c29b54459a326b5ff244685dd2765bcd19adf.

from conjure.

scotts777 avatar scotts777 commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

I'll try a stripped down neovim soon and see if I can reproduce it there. I would put money on this being some weird setting that most people have set that might not be set by default. It's so odd how the Lua, Clojure and VimL is all up and talking to each other but still manages to get a nil where it shouldn't.

That nil means it couldn't find the Conjure buffer/window. This could be a race condition (ahhhhh) or it could just be a setting on the buffer / neovim instance. I'll work it out πŸ˜„

from conjure.

scotts777 avatar scotts777 commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

Ah! OSX's /tmp is a symlink if I'm not mistaken to /private/tmp or something of the sort. Could you confirm that the Conjure buffer isn't in the place I expect by running :echo expand("%:p")? I bet it's not /tmp/conjure.cljc. I'll start looking for a better solution that should work for you now, if that is indeed the problem.

from conjure.

Olical avatar Olical commented on May 14, 2024

If my hunch is correct, this commit should fix it! If you get a chance to give it a go let me know how it goes πŸ˜„ 3918cbc

from conjure.

scotts777 avatar scotts777 commented on May 14, 2024

from conjure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.