Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init.vim not being loaded #1089

Closed
igorcafe opened this issue Dec 6, 2022 · 9 comments
Closed

init.vim not being loaded #1089

igorcafe opened this issue Dec 6, 2022 · 9 comments

Comments

@igorcafe
Copy link

igorcafe commented Dec 6, 2022

I don't know why, but it seems that my init.vim is being completely ignored...

VSCode settings.json:

{
  "vscode-neovim.neovimExecutablePaths.linux": "/usr/bin/nvim",
  "vscode-neovim.neovimInitVimPaths.linux": "/home/igor/.config/nvim/init.vim", 
}

/home/igor/.config/nvim/init.vim

set number    
set relativenumber    
     
nnoremap <C-d> <C-d>zz    
nnoremap <C-u> <C-u>zz    

Expected behavior:

  • relative line numbers
  • ctrl D and ctrl U centered
expected.mp4

Actual behavior:

  • default line numbers
  • crazy ctrl D and ctrl U
actual.mp4

nvim version: 0.8.1 (snap)
VSCode version: 1.73.1

@MNThomson
Copy link

Ah, another cultured @ThePrimeagen viewer I see... I spent ~6hrs last weekend trying to solve this exact problem and think I've figured out as to why (don't take my word for fact).

Relative Line Numbers

- Editor customization (relative line number, scrolloff, etc) is handled by VSCode.

So you'll need to change the VSCode File -> Preferences -> Settings and change the setting Line Numbers to relative

Navigation

Now this one is a bit more scuffed and what I lost most of my time to. As far as I can tell, <C-u> & <C-d> are not being sent through to NeoVim and are instead overridden by VSCode

public constructor(client: NeovimClient, revealCursorScrollLine: boolean) {
this.client = client;
this.revealCursorScrollLine = revealCursorScrollLine;
this.disposables.push(
vscode.commands.registerCommand("vscode-neovim.ctrl-f", () => this.scrollPage("page", "down")),
);
this.disposables.push(
vscode.commands.registerCommand("vscode-neovim.ctrl-b", () => this.scrollPage("page", "up")),
);
this.disposables.push(
vscode.commands.registerCommand("vscode-neovim.ctrl-d", () => this.scrollPage("halfPage", "down")),
);
this.disposables.push(
vscode.commands.registerCommand("vscode-neovim.ctrl-u", () => this.scrollPage("halfPage", "up")),
);
this.disposables.push(vscode.commands.registerCommand("vscode-neovim.ctrl-e", () => this.scrollLine("down")));
this.disposables.push(vscode.commands.registerCommand("vscode-neovim.ctrl-y", () => this.scrollLine("up")));
}

/// SCROLL COMMANDS ///
private scrollPage = (by: "page" | "halfPage", to: "up" | "down"): void => {
vscode.commands.executeCommand("editorScroll", { to, by, revealCursor: true });
};

I don't believe with the extension you can really remap most of the <C-*> keys right now unfortunately. To check if your init.vim is actually being run, try remapping keys instead like the below:

nnoremap gk zz

Thus if you can type gk in normal mode and have it center to screen, you know in fact your init.vim is actually being read.

Disclaimer: I only started using this extension last week and have absolutely no clue what I'm talking about. If someone who's worked on the extension knows more, please correct me

@theol0403
Copy link
Member

This is correct. Your init.vim works, but you've managed to test two (somewhat unique) cases where the effect does not apply to vscode.

  1. Neovim UI settings are not sent over to vscode, the UI (line numbers, etc) is all handled by vscode. It is on my roadmap to support some settings Implement smart line numbers #656 (comment)
  2. Scrolling is currently a mess. I plan to write about this in an annoucement when I have the chance. Basically, currently scrolling is handled by vscode (using behavior that does not match nvim's). There are a bunch of PRs that work to fix this, but they are currently in a semi-working state. Ref: fix(scrolling): fix c-u/c-y/c-f/c-b by deletion #885 (comment)

@theol0403
Copy link
Member

To clarify: there is currently no neovim scroll position -> vscode sync, which means that C-u commands that just move the nvim viewport don't work without intervention.

@theol0403
Copy link
Member

theol0403 commented Dec 6, 2022

Also I'm curious - what does ThePrimeagen have to do with this? Did he mention the plugin somewhere?

@MNThomson
Copy link

Whoops, didn't mean to actually ping Prime. He mentioned the <C-u>zz remap in a recent video @theol0403 : Vim As Your Editor - Vertical Movements

@ThePrimeagen
Copy link

i have been summoned and i am happy to see such wonder remaps in play! May the coconut oil flow as if its 85 degrees in your room.

@Andrew-Pynch
Copy link

@MNThomson @theol0403

So just to confirm.

It is not currently possible to reproduce the ctrl + d nnoremap to center when ctrl + d is pressed within this extension currently?

I just got it working in vanilla vim and was hoping to reproduce this effect in nvim/vscode.

@KatlehoJordan
Copy link

Any place I can "upvote" this as a feature request for the plugin? Would love to rapidly re-center my VS-code editor panes by appending zz after various different keystroke-combinations, ❤️.

Thanks for this great extension! Terrific way to start learning nvim in the comfort of VS Code!

@theol0403
Copy link
Member

Being worked on in #993

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants