MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.73k stars 255 forks source link

Switch between source and header #705

Open maujim opened 3 years ago

maujim commented 3 years ago

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.

myrgy commented 3 years ago

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

maujim commented 3 years ago

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.

GGCristo commented 3 years ago

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.

bfrg commented 3 years ago

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

pvonmoradi commented 3 years ago

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.

ericcurtin commented 3 years ago

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

maujim commented 3 years ago

@MaskRay any update on this?

hinell commented 11 months ago

Any progress on this? Just wonder.