RasmusLindroth / tut

TUI for Mastodon with vim inspired keys
https://tut.anv.nu
MIT License
449 stars 29 forks source link

SOLVED: Can't use neovim as editor: file always read only #150

Closed m040601 closed 2 years ago

m040601 commented 2 years ago

This is maybe not an "issue" with tut, but more of a call for help to troubleshoot my neovim editor use with tut.

Have been wraping my head for many months with this.

I always get a "read only" tut temporary file created in "/tmp" using neovim

I "thought", I was experiencing a similar problem with nvim, as reported here, https://github.com/RasmusLindroth/tut/issues/144, with 'vis'

But then I created a fresh new user with no "neovim" or "tut" configuration. And I have no problem running

EDITOR=nvim tut

So now I "think" I have some problem with my personal neovim use.

I just can't figure it out what it is. My Archlinux system is standard. No unsual configuration or hacks. Every new file opened with neovim opens some "nvimXYZ" temp dir in "/tmp"

    $ type vi
vi is /usr/bin/vi
    $ type nvim
nvim is /usr/bin/nvim
$ echo $EDITOR
/usr/bin/nvim

Start tut. Hit 'c' compose. Hit 'e' edit. I get this temporary file for the toot as "RO" readonly:

0/1)tut885954209    [RO]  [-]               text  utf-8[unix][tab 8]  All
"/tmp/tut885954209" [readonly] --No lines in buffer--

Tried starting with:

EDITOR=nvim tut

Same thing. However starting it with:

EDITOR=vi tut

Works. As with any other editor instead of nvim.

Any one else here using neovim with "tut" ?

RasmusLindroth commented 2 years ago

I also use neovim, but don't experience this problem. Could you post your ~/.config/nvim? If it's large or contains anything you don't want to share with everyone you can send it to rasmus@lindroth.xyz.

My guess is that you have some plugin or some setting that is causing this as it works with other editors and on a different user.

Could you also compose a new tut and with the editor open run ls -la /tmp/tut* in new terminal. It should display something like -rw------- 1 rasmus rasmus 0 May 23 19:38 /tmp/tut774170828.

m040601 commented 2 years ago

I solved my problem !

ls -la /tmp/tut* in new terminal. It should display something like -rw------- 1 rasmus rasmus 0 May 23 19:38 /tmp/tut774170828.

Yes it does display "rw" as expected.

Could you post your ~/.config/nvim

Thanks for your kind help. As suspected, that's where the problem was. I was to "ashamed" to post and show my neovim messy config :) ...

But anyway I found the culprit.

It was a little snippet I had to view inside neovim binary or unknows file types. This is done used the great "lesspipe" helper of less, https://github.com/wofr06/lesspipe/wiki/vim

Unfortunately it some how messes up during the time that "tut" is "sending" the text buffer to be handled by neovim.

That snippet mysteriously kicks in too soon and marks that ""/tmp/tutXXXXXX" file as readonly and nonmodifiable. Although neovim still identifies it as filetype "text"

0/1)tut3814409942    [RO]  [-]                            text  utf-8[unix][tab 8]  All
  filetype=text

Probably that " autocmd BufReadPost * ...." needs some adjustment. But I dont know how. Not a vimscript expert. Anyway I know how to cope with this situation.

Might be usefull to know for future tut users with similar problems.

Thanks any way and keep up the excelent work !