ccls icon indicating copy to clipboard operation
ccls copied to clipboard

Switch between source and header

Open maujim opened this issue 5 years ago • 8 comments

I don't believe that this is a feature in the official LSP spec but it is implemented by clangd so I thought it to be worth asking.

Is there any plans to implement the ability to switch between source and header files?

If there is a better place to ask about features, I can move this to there.

maujim avatar Oct 08 '20 22:10 maujim

projectile does it. might be a good replacement https://github.com/bbatsov/projectile/blob/master/projectile.el#L1942

myrgy avatar Oct 23 '20 11:10 myrgy

Thanks for the suggestion but I'm on vim so that wouldn't work.

The closest thing I've found so far is a special register in vim, %<, that contains the name of the current file without the extension. So for example, if I'm editing src/foo/Bar.cpp, the command :e %<.hpp will open up src/foo/Bar.hpp.

If nothing comes up, I'll probably write up a small vim plugin to do this.

maujim avatar Oct 23 '20 18:10 maujim

I use (https://github.com/ericcurtin/CurtineIncSw.vim), its very small and if you are ok with the assumptions its the way to go. You can also take a look at he wiki (https://vim.fandom.com/wiki/Easily_switch_between_source_and_header_file). None of these are code aware, they use patterns/regex but maybe that is ok for you.

GGCristo avatar Oct 25 '20 15:10 GGCristo

There's also vim-projectionist where you can define alternate files, like source and header files (among many other things).

bfrg avatar Nov 26 '20 16:11 bfrg

Any updates on this? I use CoC and there is this line in my vimrc

" switch between header and implementation file
nmap <leader>ch :<C-u>CocCommand clangd.switchSourceHeader<CR>

which of course doesn't work with ccls. It would be great if I could generalize this line to include ccls.

pvonmoradi avatar Dec 16 '20 11:12 pvonmoradi

Thanks for using my plugin @GGCristo ! I wrote a new little one recently. Feel free to try and star if you like! :smile:

https://github.com/ericcurtin/VimBlame.vim

ericcurtin avatar Feb 19 '21 10:02 ericcurtin

@MaskRay any update on this?

maujim avatar May 27 '21 16:05 maujim

Any progress on this? Just wonder.

hinell avatar Oct 23 '23 15:10 hinell