LoricAndre / OneTerm.nvim

One terminal plugin to rule them all ! (eventually)
54 stars 1 forks source link

New command ideas #2

Open LoricAndre opened 3 years ago

LoricAndre commented 3 years ago

I need ideas for new commands, so comment here anything you might want !

aMOPel commented 3 years ago

What you think about a command that opens just a terminal in the current workspace to run some quick code while editing. But the terminal is persistent, so that you can execute your program or whatever, esc out, edit some, use some other one term commands, come back to the terminal, and you still have the output etc. I just like the floating thing more than the standard neovim term.

LoricAndre commented 3 years ago

This should be feasible, I'll look into it EDIT : done with 25b41e17a61ce35a929199f5a1b5c01c0752c16e to 886d951 EDIT2: I'll document shortly, I forgot

aMOPel commented 3 years ago

so how do you exit it again? since it captures all the keyinput, because by typing exit of course you kill the instance.

LoricAndre commented 3 years ago

You can use <C-\><C-n> to get back to normal mode

aMOPel commented 3 years ago

alright, but it doesnt stop rendering the floating window, i can jump outside but the floating window is still in front and if i close it with "c-w c" my vim crashes. free(): invalid size zsh: abort (core dumped) nvim -S ./Session.vim

LoricAndre commented 3 years ago

I'm looking into this, a stable version should be up shortly.

LoricAndre commented 3 years ago

Well it should be working now

LoricAndre commented 3 years ago

And btw you still need to close the window when you're down (if you delete the buffer it will open a new shell instance).

aMOPel commented 3 years ago

first i got this error when closing the window Error executing vim.schedule lua callback: vim.lua:492: Vim(source):E484: Can't open file /tmp/o neterm

then i manually created the file and had no error when closing the windows, but still calling ":OneTerm term" again opens a new instance, old output is gone

LoricAndre commented 3 years ago

The first issue is easy to fix and I'll work on it tomorrow (meaning in ~16h) How do you close the window ? The file should be created anyway unless you exit the shell early

aMOPel commented 3 years ago

so i exit terminal mode with <c-\><c-n> and then use <c-w>c which i didnt remap which executes :close

LoricAndre commented 3 years ago

All right, it's weird cause I tested it by closing it this way. Can you check if g:oneterm_term_buf changes every time you open a new window?

aMOPel commented 3 years ago

it does indeed, went from 9 to 10

LoricAndre commented 3 years ago

All right, thanks, I'll look into it tomorrow. The other commands are working for you (apart for #3)?

aMOPel commented 3 years ago

well files isnt working since it depends on rg and i only have ag currently (and fd-find ) but thats to be expected.

now that i tested :OneTerm buffers i saw that the terms are actually there

the :OneTerm make listed some makefiles but it didnt compile on enter, also without the path of the makefile im missing the context which is which, also im getting no targets, only makefiles. but im using <leader>m for compiling and have a dedicated .exrc file in the project root to set makeprg because i also specify a -C flag for the command

symbols works for me, i have nvim-lspconfig, but ws_symbols doesnt give me anything

also what i noticed is that its a little annoying that for every match with fzf there is the full absolute path, usually there is little space left for the actual match, so maybe an omision or a compression of parts of the path would be nice.

also another idea would be to add snippet search

aMOPel commented 3 years ago

references is giving me results but opens nonsense ~/learncpp/src/main.cpp 27 Mystring string{ this is the buffer name and the buffer is empty when i jump to a reference

aMOPel commented 3 years ago

and yank isnt working for me i have let g:var_oneterm_yank = 1 in my vimrc and i get

Error detected while processing function Oneterm_cmd: line 2: E5108: Error executing lua [string "luaeval()"]:1: attempt to call field 'yank' (a nil value)

is there some dependency or smth?

basilgood commented 3 years ago

It would be great if OneTerm commits were colorful. It's almost useless without syntax because it's hard to see the diffs. And would be useful OneTerm bcommits to see diffs for current buffer only. For OneTerm rg it would be useful if the results had line numbers. Thanks for your work.

LoricAndre commented 3 years ago

also what i noticed is that its a little annoying that for every match with fzf there is the full absolute path, usually there is little space left for the actual match, so maybe an omision or a compression of parts of the path would be nice.

Could you please open an issue for this please ? It will take some time & work but I'll try

LoricAndre commented 3 years ago

and yank isnt working for me i have let g:var_oneterm_yank = 1 in my vimrc and i get

Error detected while processing function Oneterm_cmd: line 2: E5108: Error executing lua [string "luaeval()"]:1: attempt to call field 'yank' (a nil value)

is there some dependency or smth?

The actual command is yanks, The s is missing from the completion function and doc. I'll push this soon

aMOPel commented 3 years ago

I see, also the last time I looked term wasn't in the completions

basilgood commented 3 years ago

Neovim has now native floating border. It could be easy to put in function getopts() local opt: border = 'single'

LoricAndre commented 3 years ago

Neovim has now native floating border. It could be easy to put in function getopts() local opt: border = 'single'

I saw this, that's why I created g:oneterm_options, you can simply put it in there !

LoricAndre commented 3 years ago

I fixed most of the issues above, apart from @aMOPel 's term issue, ws_symbols and make. I've also added bcommits.

LoricAndre commented 3 years ago

The paths on the lsp matching are now relative btw

LoricAndre commented 3 years ago

@aMOPel could you also please open an issue for the problem you have with term please ? I can't reproduce it...

LoricAndre commented 3 years ago

the :OneTerm make listed some makefiles but it didnt compile on enter, also without the path of the makefile im missing the context which is which, also im getting no targets, only makefiles. but im using <leader>m for compiling and have a dedicated .exrc file in the project root to set makeprg because i also specify a -C flag for the command>

Did you run the command with a Makefile in neovim's working directory ?

aMOPel commented 3 years ago

the :OneTerm make listed some makefiles but it didnt compile on enter, also without the path of the makefile im missing the context which is which, also im getting no targets, only makefiles. but im using <leader>m for compiling and have a dedicated .exrc file in the project root to set makeprg because i also specify a -C flag for the command>

Did you run the command with a Makefile in neovim's working directory ?

not in the root of the working directory but in a folder 1 below

LoricAndre commented 3 years ago

About ws_symbols, not many language servers support it, so in those cases it will be empty. I tested it in python with jedi and it works.

LoricAndre commented 3 years ago

the :OneTerm make listed some makefiles but it didnt compile on enter, also without the path of the makefile im missing the context which is which, also im getting no targets, only makefiles. but im using <leader>m for compiling and have a dedicated .exrc file in the project root to set makeprg because i also specify a -C flag for the command>

Did you run the command with a Makefile in neovim's working directory ?

not in the root of the working directory but in a folder 1 below

Ok that's why it isn't working, I'm only detecting targets for neovim's pwd. I'll try making the plugin walk a few directories up

aMOPel commented 3 years ago

the :OneTerm make listed some makefiles but it didnt compile on enter, also without the path of the makefile im missing the context which is which, also im getting no targets, only makefiles. but im using <leader>m for compiling and have a dedicated .exrc file in the project root to set makeprg because i also specify a -C flag for the command>

Did you run the command with a Makefile in neovim's working directory ?

not in the root of the working directory but in a folder 1 below

Ok that's why it isn't working, I'm only detecting targets for neovim's pwd. I'll try making the plugin walk a few directories up

i mean i work with cmake and it makes a folder for debug for example and in there is the makefile generated. however i make the project root vims working dir and have a session file there from which i continue working. and then i have a .exrc set makeprg=make\ -C\ ./debug so i can call :make in vim, but i guess i could also symlink the makefile in the root. but then what about different builds like release..

ex: vim working dir is just project/ project/src/main.cpp etc. project/debug/makefile

aMOPel commented 3 years ago

About ws_symbols, not many language servers support it, so in those cases it will be empty. I tested it in python with jedi and it works.

i see, that makes sense

aMOPel commented 3 years ago

will you add a snippet search?

LoricAndre commented 3 years ago

the :OneTerm make listed some makefiles but it didnt compile on enter, also without the path of the makefile im missing the context which is which, also im getting no targets, only makefiles. but im using <leader>m for compiling and have a dedicated .exrc file in the project root to set makeprg because i also specify a -C flag for the command>

Did you run the command with a Makefile in neovim's working directory ?

not in the root of the working directory but in a folder 1 below

Ok that's why it isn't working, I'm only detecting targets for neovim's pwd. I'll try making the plugin walk a few directories up

i mean i work with cmake and it makes a folder for debug for example and in there is the makefile generated. however i make the project root vims working dir and have a session file there from which i continue working. and then i have a .exrc set makeprg=make\ -C\ ./debug so i can call :make in vim, but i guess i could also symlink the makefile in the root. but then what about different builds like release..

ex: vim working dir is just project/ project/src/main.cpp etc. project/debug/makefile

I'll try using makeprg then ! EDIT : done with 2938f81b34d9466ea8523ca6a634c19f57dd5853

LoricAndre commented 3 years ago

will you add a snippet search?

I'll try to, at least with UltiSnips there has to be a way since fzf.vim did it

basilgood commented 3 years ago

Oldfiles or History it would be useful.

LoricAndre commented 3 years ago

Do you mean command history ?

LoricAndre commented 3 years ago

Oldfiles is done !

aMOPel commented 3 years ago

Oldfiles is done !

for recent files you could use the .fasd file if fasd is installed

aMOPel commented 3 years ago

the :OneTerm make listed some makefiles but it didnt compile on enter, also without the path of the makefile im missing the context which is which, also im getting no targets, only makefiles. but im using <leader>m for compiling and have a dedicated .exrc file in the project root to set makeprg because i also specify a -C flag for the command>

Did you run the command with a Makefile in neovim's working directory ?

not in the root of the working directory but in a folder 1 below

Ok that's why it isn't working, I'm only detecting targets for neovim's pwd. I'll try making the plugin walk a few directories up

i mean i work with cmake and it makes a folder for debug for example and in there is the makefile generated. however i make the project root vims working dir and have a session file there from which i continue working. and then i have a .exrc set makeprg=make\ -C\ ./debug so i can call :make in vim, but i guess i could also symlink the makefile in the root. but then what about different builds like release.. ex: vim working dir is just project/ project/src/main.cpp etc. project/debug/makefile

I'll try using makeprg then ! EDIT : done with 2938f81

works for me

LoricAndre commented 3 years ago

History done (it lists command history) !

LoricAndre commented 3 years ago

Oldfiles is done !

for recent files you could use the .fasd file if fasd is installed

I'm not using that but it seems interesting ! EDIT : For files you've edited in neovim, it keeps a list in v:oldfiles so I don't really need it

basilgood commented 3 years ago

Wow you're awesome. Oldfiles it's what I wanted. Thank you very much. It works perfectly.

basilgood commented 3 years ago

An awesome feature would be term to be toggle and keep the session.

LoricAndre commented 3 years ago

This is how it's supposed to work, see #5 for progress and the issue and to help me debug it ! EDIT : you need set hidden for it to work since I have to keep the buffer alive

basilgood commented 3 years ago

I watched the debugging on the #5 but it doesn't work for me. set hidden? hidden OneTerm term open terminal <C-\><C-n> and OneTerm term and nothing happens. maybe I'm doing something wrong?

LoricAndre commented 3 years ago

<C-\><C-n> will put you in normal mode, you have to close the window afterwards. Then, invoking the command again should open the same terminal instance

basilgood commented 3 years ago

Yes, I tested it and it works perfectly. Thank you.

aMOPel commented 3 years ago

Yes, I tested it and it works perfectly. Thank you.

you can use this mapping to easily close it tnoremap <c-w> <c-\><c-n><c-w>c

basilgood commented 3 years ago

I have this:

vimp.nmap([[<C-\>]], ":OneTerm term<cr>")
vimp.tnoremap([[<C-\>]], '<C-\\><C-n>:q<cr>')

Thank you.