Error detected while processing InsertEnter Autocommands: E117: Unknown function: jedi#remove_usages - vim

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

Related

Error CocAction("extensionStats") does not work

Every time I enter neovim in windows 10 to a .js file I get this error:
Error detected while processing function SwitchFlowOrTsLsps[1]..CocAction:
line 2:
E605: Exception not caught: coc.nvim not ready when invoke CocAction "extensionStats"
In my configuration file is the function for which the error occurs:
function! SwitchFlowOrTsLsps(flowIndex)
silent let stats = CocAction("extensionStats")
silent let tsserver = get(filter(copy(stats), function('FindTsServer')), 0)
if(a:flowIndex == 0)
if(tsserver.state == 'disabled')
call CocActionAsync("toggleExtension", "coc-tsserver")
endif
else
if(tsserver.state == 'activated')
call CocActionAsync("toggleExtension", "coc-tsserver")
endif
endif
endfunction
Could someone help me? Although to tell me to delete the function, that function along with some more configurations I copied them from github and I don't understand it, I don't understand what it does.
It could even be a Coc error, that's how I see it but I'm not sure how to fix it, I have coc-json and coc-tsserver installed, if I need any more just say so.
Thank you all.
coc.nvim not ready when invoke
You need to make sure your coc.nvim has started already before invoke this action.

Indenting multilines/block with vscode and vim plugin

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"]
}
]

How to make cljs files works with figwheel repl via fireplace.vim?

I have a project on ClojureScript and I'm using vim for code editing, so I want to access repl inside editor, what is accessible using fireplace.vim.
It works well if you have a brand new flat project - you just open the directory, start clojure repl, open vim in the same directory, create an expression and evaluate it using cpp.
https://youtu.be/vHDLDNoAdLE
But when I working with figwheel project I want to connect to figwheel repl in order to calculate something from cljs file, so I start a figwheel which starts the repl on port 7888 eventually and connect to that repl with fireplace using :Connect command and it works for only clj files, not for cljs.
https://youtu.be/ue42Yh0v6UQ
When I'm trying to evaluate an expression in .cljs file fireplace throwing this error:
Error detected while processing function
37_printop1..37_opfunc[35]..fireplace#client: line 10:
E605: Exception not caught: Fireplace: class
java.lang.ClassNotFoundException
Does anyone have any idea how to make it work (fireplace + .cjls files)?
The problem was in fireplace.vim plugin
at line 323 in fireplace.vim
let response = connection.eval("((or (resolve 'cider.piggieback/cljs-repl)"
must be line:
let response = connection.eval("((or (resolve 'cider.piggieback/wrap-cljs-repl)"
because cider.piggieback defines wrap-cljs-repl function in line 299:
(defn wrap-cljs-repl [handler]
Have you "Piggiebacked" ("enable the use of a ClojureScript REPL on top of an nREPL session") to connect Fireplace to the Figwheel REPL?
:Piggieback (figwheel-sidecar.repl-api/repl-env)
See https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-with-Vim#still-in-vim-piggieback-on-clojurescript
Related to ClassNotFound Exception cemmerick.piggieback:
You have to include cemerick.piggieback in your project.clj or profiles.clj. See https://github.com/nrepl/piggieback:
:profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.1"]
[figwheel-sidecar "0.5.18"]]
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}
Here is a sequence of steps I took to make work figwheel REPL with vim fireplace:
Add these dependencies to /home/{username}/.clojure/deps.edn:
...
:aliases {:nrepl
{:extra-deps
{nrepl/nrepl {:mvn/version "0.6.0"}
cider/cider-nrepl {:mvn/version "0.23.0"}
cider/piggieback {:mvn/version "0.4.2"}}}}
...
Add these ones to the project:
...
:deps {com.bhauman/figwheel-main {:mvn/version "0.2.3"}
figwheel-sidecar {:mvn/version "0.5.19"}}
...
Run a project from a terminal with the next command:
clj -R:nrepl -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]"
Connect to an nREPL from vim using:
:Connect nrepl://localhost:{port}
Start a figwheel REPL and connect to it:
:CljEval (do (require 'figwheel.main.api) (figwheel.main.api/start "dev"))
:CljEval (do (use 'figwheel.main.api) (figwheel.main.api/cljs-repl "dev"))

How to set clang-format options in local vimrc (.lvimrc) file?

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.

How to connect fireplace.vim to browser repl

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

Resources