Hot answers tagged

3

:read inserts text from a given file. When you start with empty file, it already has one (virtual, empty) line. So if you do :0read then the text is added after 0th line (that is, before the first and only line), and then the former line #1 gets shifted to the end of file. You can't prevent it, only to remove it. Personally, I'd prefer :read filename | ...


3

The C API of Python evolves with the version of Python. In this case, function PySlice_AdjustIndices was introduced in this commit to supercede function PySlice_GetIndicesEx, but it seems this function was only released starting with Python 3.5.4 and 3.6.1. Since your Vim seems to default to pythonthreedll=python36.dll (inferred from error message E370: ...


2

In my case I had to run this command: pip3 install --user jedi


2

I haven't had time to test more than the first code-block, but the others are mostly mechanical transformations. function MyLinks(pat, strip) abort return glob(a:pat, v:false, v:true) \ ->map({_, v -> printf('[%s](%s)', fnamemodify(v, ':t:r')->substitute(printf('^%s', a:strip), '', ''), fnamemodify(v, ':t'))}) \ ->join("\n&...


2

There are a few minor issues with most of your lines ignoring specific patterns. %-G%Oh no!\ %m : You have an extra % there, turning the first character into a %O (a command to overread the matched part) rather than a literal O. You also have a trailing space there, so it would only match a line with a space at the end! You can fix that to %-GOh no!\ %m. ...


2

As we sussed out in the comments, this is from ALE+mypy, which needs to be installed in the virtual-env of the project. Why? I'm not 100% sure, but I suspect mypy is simply ignorant of virtual-environments. It probably uses its installation location to find modules (possibly via the file-system; more likely via dynamic import/eval wizardry).


2

It is actually the expected behavior, although that is clearly not what was intended. The key is that 'termwinsize' is "local to window", whereas 'buftype' is "local to buffer". There is a slight --- but important --- distinction between "window" and "buffer". :h windows.txt explains this distinction in great detail. ...


1

Because my system does not name the default python interpreter as python3, but as python I simply added a shell alias: alias python3='python'


1

The syntax error is happening because the function call is passing an async=True keyword argument. The async term has become a reserved keyword in recent Python, so it's not allowed as a keyword argument anymore. If you load this source code in a Python interpreter, it's quite possible that it won't complain about it right away. Python is an interpreted ...


1

EDIT You also need to add the following line to your vimrc: filetype plugin indent on See :h :filetype-plugin-on and :h :filetype-indent-on this command enable the filetype detection and the loading of the indent scripts which are necessary to have working folding. You can't set foldmethod directly from the vimrc, see :h 'fdm': 'foldmethod' 'fdm' string (...


1

A substitution like this works for all scenarios: %s/print(\(.*\))/log.info(" ".join([\1]))/ Grab everything within print brackets (.*) using regex replace the match with a join statement surrounding the match replace the print with log.info (or whatever is required) Here is the test script if anyone wants to try it for themselves: import logging,...


1

I followed the instructions given by puremourning at https://www.reddit.com/r/vim/comments/mbdt2e/environment_variables_on_vimspector/ I used a shell variable to run a script whose output is the JSON required for the env key; and type coercion to coerce this JSON string into the env map It is illustrated in puremourning's example: shell variable: https://...


1

You can create a function for that (easier with python :h if_pyth). # intial setup import inspect` potential_modules = ['django', 'sys', 'os'] for module_name in potential_modules: exec(f"from {module_name} import *") def add_import_on_trigger() func_name = get_the_word_under_cursor(); module_name = inspect.getmodule(func_name) ...


1

Remove the lines that open the quickfix list (:copen). Aside—if you use :execute for simple Ex commands, it’s usually enough to do just the command (so just :copen, :wincmd p, etc.). Even the colon’s aren’t necessary in most places.


1

If using vimspector, you can set the python launch argument to point to the python interpreter that debugpy uses to debug your application. It's even in the example https://github.com/puremourning/vimspector#python


1

If you have a Vim version with Python support (you can check that in vim --version or :version and see if you have +python3 or +python3/dyn), then you can use py3eval() to evaluate the expression inside Vim itself. This should work: xnoremap <Leader>p c<C-R>=py3eval(@")<CR><Esc> (Note: This assumes Python 3. There are similar ...


1

As Martin points out in the comments, this has been fixed. Either update vim or add the newer syntax file to your configuration.


Only top voted, non community-wiki answers of a minimum length are eligible