I am using Local vimrc for project specific vim settings. I have the .lvimrc file in my project directory with specific settings as shown below and it works.
set tabstop=2
set shiftwidth=2
set softtabstop=2
But, I am unable to override the clang-format settings, for e.g when I run :ClangFormat, vim still uses the settings present in .vimrc file in my home folder
I have the following clang-format setting inside the .lvimrc file.
let g:clang_format#style_options = {
\ "Language": "Cpp",
\ "IndentWidth": 2,
}
Local vimrcs should define local options with setlocal, and let b:option_name = value.
Unfortunately not all plugins understand that some users can work on several projects simultaneously. In that case, you need your local vimrc plugin to always load local vimrc files every time you enter a buffer (even if it was already opened). And then you can protect the buffer local definitions to be (re)set again.
I can not speak for the plugin you're using. Mine reloads vimrc_local.vim files everytime we BufEnter a buffer. As a consequence the local vimrc file looks like
" -- Global Overridden zone for project unaware plugins
let g:some_global_option_overwritten_every_time = "forced value"
" -- Buffer local zone for project-aware plugins
if exists('b:project_foo_bar_lvimrc_loaded') && b:project_foo_bar_lvimrc_loaded != 0
finish
endif
let b:project_foo_bar_lvimrc_loaded = 1
setlocal whatever=value
let b:some_option_for_a_smart_plugin = "specific value"
" -- and we can also add a global zone for stuff that we can load once
" like functions, but it'll be smarter to use autoload plugins
BTW, reading the plugin documentation, it looks like it also listen BufEnter, and unlike my plugin it seems to automatically set guards. One other possibility is that your project is in a blacklisted directory tree. You'll have to check that also.
Related
I just installed NvimTree plugin to my neovim setup and i get annoyed by the y/n prompt when i am deleting a file. How to disable it?
Nvim's user-specific configuration file is located at
$XDG_CONFIG_HOME/nvim/init.vim, by default ~/.config/nvim/init.vim
add the following line to your configuration file:
let g:NERDTreeConfirmDelete = 0
I'm trying to setup vim-jedi on neovim.
Whenever I open a python file and switch to Insert mode I get the following error:
Error detected while processing InsertEnter Autocommands for "<buffer=1>":
E117: Unknown function: jedi#remove_usages
I'm really new to (neo)vim so I'd really appreciate if could help me resolve this issue, thanks!
Below, I'm providing the information I think is relevant. Please let me know if you require me to provide anything else.
My setup
First I installed vim-jedi from pacman then I set my init.vim file to the following.
" My .nvimrc(init.vim) file
"
:set number relativenumber
:set termguicolors
" Plugins
call plug#begin()
" Solarized theme
let g:neosolarized_contrast = "normal"
set background=dark
Plug 'iCyMind/NeoSolarized'
" Python Completions via jedi
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
call plug#end()
" Select Solarized as my theme.
colorscheme NeoSolarized
Afterwards I
Ran :PlugInstall
Restarted nvim
Ran :PlugUpdate
Restarted nvim and opened my file with nvim db.py.
The file I opened contains the following:
"""Database management functions"""
import tasks3.tasks3.db as db
def init(db_path: str):
engine = db.create_engine(db_path)
Base.metadata.create_all(bind=engine)
def purge(db_path: str):
engine = db.create_engine(db_path)
session = db.orm.sessionmaker(bind=engine)
def drop(db_path: str):
pass
To the best of my knowledge I don't have any additional scripts for nvim.
Additional Note (not sure if this is related)
In the context of the above purge function if type session. I get the following message:
-- Omni completion (^O^N^P) Pattern not found
This is already on the site, but it doesn't work for me. I'm not 100% sure the answer is responsive to my situation (the question asks about vim "mode"). If it is, the context for the accepted answer isn't obvious for me.
I assume were supposed to splice the json fragment
{
"key": "shift+tab",
"command": "outdent",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus"
}
into our settings but it's not clear how or where. The app has a settings.json, a keybindings.json and the plugin has package.json.
I got this to work in vim itself a year or so ago IIRC, but it took a plugin and a couple of settings.
Edit to add: ctrl+[ and ctrl+] aren't functional for me. Presumably they would be w/o the vim plugin, but the plugin overrides the ctrl commands.
Just as in normal vim, typing >> and << in normal mode or > and < in visual mode will indent and un-indent lines, respectively.
Source: https://vim.fandom.com/wiki/Shifting_blocks_visually
Also: https://stackoverflow.com/a/235841/7007605
If you are using the main Vim (VSCodeVim), the standard m>, m<, :m,n>, :m,n< are not supported (see https://github.com/VSCodeVim/Vim/issues/3733).
However, this feature is supported by the Neo Vim VS Extension (asvetliakov.vscode-neovim). Note that if you go this route, you do need to install neovim (>v0.5.0) separately, which you can obtain at https://github.com/neovim/neovim/releases/nightly. Then set the path to the neovim executable/binary in the Neo Vim VS extension settings.
I remaped < and > in normal mode to ident lines while using the VSCode commands:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<"],
"commands" : ["tab"]
},
{
"before": [">"],
"commands" : ["outdent"]
}
]
Im working on project that is in fact composed of several subproject, under a common git repository:
Project
- Sub Project A
- Sub Project B
- ...
I never work on the main folder, and always start from one of the sub projects, the problem is no matter what I try CtrlP always does the search starting from the main folder where the repo is.
I've tried a few settings from the project repo but no matter, such as bellow, but still can't get it to make any effect.
let g:ctrlp_working_path_mode = 'ca'
Any tips please?
Looking at the CtrlP docs suggests that you have three options:
Disable CtrlP's working directory searching: let g:ctrlp_working_path_mode = ''. It will then only search under Vim's current working directory, so just :cd to one of your sub projects' directories.
Ignore the sub project directories that you are not interested in: let g:ctrlp_custom_ignore = { 'dir': '\v[\/]Sub Project [AB]$' } (untested).
Add Sub Project A, Sub Project B, etc. as root markers: let g:ctrlp_root_markers = ['Sub Project A', 'Sub Project B']. This should stop CtrlP from traversing up beyond those sub directories.
I would suggest the first option since the others are a bit too hacky for my taste. The last option also didn't work for me in a quick test.
If you're used to CtrlP starting in your current working directory, and it suddenly seems to have stopped, it's probably a side effect of g:ctrlp_working_path_mode that is a bit unintuitive: it searches up the directory tree until it finds a source control root (like a .git folder), and treats that as the top level directory.
I'm used to it always being the top level of my current project, so when I started a new project, and it was using my home directory as the root, I was confused. It's because I hadn't yet initialized Git for the new project, so the first .git directory it found was in my home directory.
Initializing a Git repo for the new project made it behave as expected.
Here's the relevant section of the plugin help:
'g:ctrlp_working_path_mode'
When starting up, CtrlP sets its local working directory according to this
variable:
let g:ctrlp_working_path_mode = 'ra'
c - the directory of the current file.
a - like "c", but only applies when the current working directory outside of
CtrlP isn't a direct ancestor of the directory of the current file.
r - the nearest ancestor that contains one of these directories or files:
.git .hg .svn .bzr _darcs
w - begin finding a root from the current working directory outside of CtrlP
instead of from the directory of the current file (default). Only applies
when "r" is also present.
0 or <empty> - disable this feature.
Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as
a fallback) when a root can't be found.
Note #2: you can use a b:var to set this option on a per buffer basis.
Is it possible to connect vim.fireplace to a browser repl ? I have a setup using austin but if I try to evaluate something inside vim I get:
org.mozilla.javascript.EcmaError: ReferenceError: "setTimeout" is not defined.
which seems to be an indicator that the browser repl is not used.
I found this discussion on Reddit to be helpful.
Specifically, I've added these commands (as suggested in the post) to my vimrc as shortcuts depending on what environment I want to connect to:
command! Piggie :Piggieback (cemerick.austin/exec-env)
command! Biggie :Piggieback (cemerick.austin/exec-env :exec-cmds ["open" "-ga" "/Applications/Google Chrome.app"])
command! Wiggie :Piggieback (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)
Now, I can
Start repl (lein repl or :Console)
Start web app in repl (e.g. (run) when using a chestnut lein template)
Open cljs buffer in vim.
Connect to repl using commands (e.g. :Wiggie)
Evaluate expressions in my buffer, and see live changes in the browser!
Yes it is possible. Browser repl, noderepl, rhino repl...
Checkout the docs and read about piggieback. That's how it handles the envs
https://github.com/tpope/vim-fireplace/blob/master/doc/fireplace.txt
https://github.com/cemerick/piggieback
Piggieback is included on Austin too so it should work if you :Connect to Austin and then :Piggieback with the environment you want
Edit: example
Read https://github.com/cemerick/austin/blob/master/README.md#usage and look at the environment that corresponds to how you started the repl. For example :Piggieback (cemerick.austin/repl-env). Look at the docs to see different repl-env that you can try.
Edit 2: Sample project Vim nRepl and node repl
Check out this project and the instructions in the readme for something similar for nodejs
https://github.com/joakin/cljs-node-repl/blob/master/README.md