Skip to content

Instantly share code, notes, and snippets.

@abadger
Created December 10, 2021 18:46
Show Gist options
  • Save abadger/aefcbc84b8f2aa5e729c0b83c845e867 to your computer and use it in GitHub Desktop.
Save abadger/aefcbc84b8f2aa5e729c0b83c845e867 to your computer and use it in GitHub Desktop.
My .vimrc.py Requires amoffat/snake
import snake
@snake.key_map("<leader>R")
def reverse():
"""Test mapping. Reverse a word"""
snake.replace_word(snake.get_word()[::-1])
@snake.key_map("<c-p>")
def toggle_gutters():
"""Turn the gutters off in normal mode to make mouse selection easier"""
line_no_value = snake.get_option('nu')
signcolumn_value = snake.get_option('signcolumn')
if signcolumn_value != 'no' or line_no_value != '0':
snake.set_option('signcolumn=no')
snake.set_option('nonumber')
else:
snake.set_option('signcolumn=yes')
snake.set_option('nu')
@snake.key_map("<c-p>", mode=snake.INSERT_MODE)
def toggle_gutters_insert():
"""Turn the gutters off in insert mode to make mouse selection easier"""
line_no_value = snake.get_option('nu')
signcolumn_value = snake.get_option('signcolumn')
if signcolumn_value != 'no' or line_no_value != '0':
snake.set_option('signcolumn=no')
snake.set_option('nonumber')
else:
snake.set_option('signcolumn=yes')
snake.set_option('nu')
# Standard vim options
snake.multi_set_option(
'ai', # Always set autoindenting to on
'ruler', # Always show the cursor position
'nobackup', # Do not keep a backp file
'incsearch', # Do incremental searching
'smartcase', # Make searches case insensitive unless they contain uppercase
'ignorecase', # by setting both ignorecase and smartcase or \C
'fo+=trocqnl1j', # Format options
'nocompatible',
'wrap', # Softwrap lines
('bs', 2), # Allow backspacing over everything in insert mode
('history', 50),
('foldlevel', 100), # Keep things unfolded by default
('encoding', 'utf8'),
('pastetoggle', '^\\'), # Allow Ctrl-\ to toggle paste mode
)
# Set a specific python3 executable
snake.let('python3_host_prog', '/usr/bin/python3.9', '', scope=snake.NS_GLOBAL)
# Ale (Linter) options
snake.let('enabled', 1, 'ale', scope=snake.NS_GLOBAL)
# snake.multi_set_option()
snake.multi_let(
'ale',
echo_msg_error_str='E', # Short error marker
echo_msg_warning_str='W', # Short warning marker
echo_msg_format='[%linter%] %code: %%s [%severity%]', # Better error message
fixers={'python': ['isort', 'remove_trailing_lines', 'trim_whitespace']}, # Enable various default fixers
# Ignore missing imports for mypy as mypy types aren't universal. This is not the same as
# imports that python can't find at all. Pylint checks that
python_mypy_options='--ignore-missing-imports --namespace-packages',
python_pyright_executable='~/.local/lib/npm_modules/bin/pyright-langserver',
#python_pylint_executable='/home/badger/bin/pylint-wrapper.py',
# Enable all fixers except mypy (Use pyre instead) and pycodestyle/pyflakes (part of pyflakes)
linters={'python': ['bandit', 'flake8', 'prospector', 'pydocstyle', 'pylama', 'pylint',
'pyls', 'pyre', 'pyright', 'vulture'], },
linters_ignore={'python': ['mypy', 'pyflakes', 'pycodestyle']},
)
# Pymode options
snake.multi_let(
'pymode',
options_max_line_length=99, # 100 as our max line length
lint=0, # Turn off linting as ale will lint instead
# lint_checker=['pylint', 'flake8', 'pylama'],
# lint_on_fly=1,
# lint_cwindow=0,
# lint_options_pep8={'max_line_length': g:pymode_options_max_line_length},
options_colorcolumn=0,
trim_whitespaces=0,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment