oscar

joined 2 years ago
[โ€“] [email protected] 1 points 1 year ago (1 children)

Oof, that's annoying.

Weird that :syntax off doesn't work, from a small test it seems to do the trick for me. But I guess as long as vim works there's no need to replace it ๐Ÿ™‚

[โ€“] [email protected] 2 points 1 year ago* (last edited 1 year ago) (4 children)

Try running this: :set indentexpr= and then :set noautoindent. Without any config file, this works for me while in a makefile that looks like this:

foo: foo.c bar.h
        $(CC) $< -o $@

The indentexpr option is set by filetype, but disabling filetype indent after already opening a makefile is too late, it would need to happen before opening it (in either a config file or directly after running nvim without any file specified).

However, indentexpr seems to only control the automatic indentation when hitting enter at the target line, but not within the recipe for it. To fix that I also had to disable autoindent.

[โ€“] [email protected] 3 points 1 year ago

Ah dang, you're right, I must have read it too quickly. Yeah then I also think it's something about not loading the config, it can be investigated by checking the runtime values like I described in my second edit.

[โ€“] [email protected] 5 points 1 year ago* (last edited 1 year ago) (10 children)

Using a the ubuntu 24.04 docker image for testing, I was able to disable automatic indentation with this config in ~/.config/nvim/init.lua:

vim.cmd("filetype indent off")

If you prefer using vim syntax it would instead be the following in ~/.config/nvim/init.vim:

filetype indent off

Note: it seems this file is not loaded if a init.lua file is present in that directory

Edit to add: So the reason this is required is, similar to vim (so you may already be familiar with this), there are filetype-specific configurations loaded. These usually reside in /usr/share/nvim/runtime/<plugin/indent/syntax/etc>/<filetype>. You can configure what files to load using the :filetype command.

There's more info here: https://neovim.io/doc/user/filetype.html

Second edit: Also when filetype indent/plugin/syntax is on, it seems to be loaded after your user config, so it overrides it. You can investigate if your actual config was applied or not by running, for example, :set autoindent? or :set cindent?. If the values do not match your configuration, it was likely overridden by :filetype. This was the case for me.

[โ€“] [email protected] 1 points 1 year ago

Gotcha. That's actually good because it will be easier to troubleshoot. I will try to reproduce in a barebones config and see if I can figure something out. What language are you editing, and what version of neovim do you use? Distro may also be relevant in case they package some indent.vim file(s).

[โ€“] [email protected] 6 points 1 year ago (13 children)

Are you using treesitter? I think that has an option to handle indentation, but I'm not sure if it's enabled by default.

[โ€“] [email protected] 3 points 1 year ago

nam is assigned the value returned by input.

This is not some edge case behavior by the input function. This is always how function calls work. You can think of it like substituting input('Who are you? ') with the value returned by it, which is the string typed in by the user in this case.

[โ€“] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

How did you install neovim? If you installed from source, double check that you followed the instructions, i.e. install build dependencies and then run:

make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install

Also, double check the version of nvim in your PATH matches:

nvim --version
[โ€“] [email protected] 1 points 1 year ago

Drop oh-my-zsh and look for something else to customize your prompt. I like Powerlevel10k but Starship is good too.

view more: โ€น prev next โ€บ