added neovim state

This commit is contained in:
Paul 2022-05-14 11:23:16 +02:00
parent 5574e33eb0
commit 3691c68cc5
8 changed files with 218 additions and 0 deletions

12
states/neovim/config.sls Normal file
View File

@ -0,0 +1,12 @@
---
{%- from "neovim/map.jinja" import neovim with context %}
neovim-neovimrc-local:
file.managed:
- name: /etc/xdg/nvim/init.vim
- source: salt://neovim/init.vim.j2
- user: root
- group: root
- mode: 0644
- template: jinja
- require:
- pkg: neovim-pkg

View File

@ -0,0 +1,89 @@
---
neovim:
enabled: true
neovimfiles_dir: /etc/xdg/nvim
colors_dir: /etc/xdg/nvim/colors
plugins_dir: /etc/xdg/nvim/pack/plugins/start
config:
options: {}
use_theme: monokai
lets:
defaults_neovim:
name: g:skip_defaults_vim
value: 1
rustfmt_autosave:
name: g:rustfmt_autosave
value: 1
ale_completion_enabled:
name: g:ale_completion_enabled
value: 1
sets:
fileencoding:
name: fileencoding
value: utf-8
fileencodings:
name: fileencodings
value: utf-8,latin1
encoding:
name: encoding
value: utf-8
eol:
name: eol
nocompatible:
name: nocompatible
nofixeol:
name: nofixeol
noignorecase:
name: noignorecase
mouse:
name: mouse=
number:
name: number
viminfo:
name: viminfo
value: "'50,<1000,s100,h"
timeoutlen:
name: timeoutlen
value: 1000
backspace:
name: backspace
value: indent,eol,start
autoindent:
name: autoindent
nocindent:
name: nocindent
ic:
name: ic
modeline:
name: modeline
incsearch:
name: incsearch
tabstop:
name: tabstop
value: 2
shiftwidth:
name: shiftwidth
value: 2
softtabstop:
name: softtabstop
value: 2
expandtab:
name: expandtab
pastetoggle:
name: pastetoggle
value: "<F9>"
laststatus:
name: laststatus
value: 2
t_Co:
name: t_Co
value: 256
t_ut:
name: t_ut
value: ""
use_syntax: true
themes:
monokai:
name: monokai
url: https://raw.githubusercontent.com/sickill/vim-monokai/master/colors/monokai.vim
plugins: {}

6
states/neovim/init.sls Normal file
View File

@ -0,0 +1,6 @@
---
include:
- .install
- .config
- .plugins
- .themes

53
states/neovim/init.vim.j2 Normal file
View File

@ -0,0 +1,53 @@
"{{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
{%- from "neovim/map.jinja" import neovim with context %}
" NeoVIM global configs
colorscheme {{ neovim.config.use_theme }}
filetype plugin on
{%- if neovim.config.use_syntax %}
syntax on
{%- endif %}
{% macro cfg(command, setting) -%}
{% for key, value in setting.items() %}
{{ command }} {{ value.name }}{% if value.value is defined %}={{ value.value }}{% endif %}
{%- endfor %}
{% endmacro -%}
" NeoVIM lets
{{- cfg("let", neovim.config.lets) }}
" NeoVIM sets
{{- cfg("set", neovim.config.sets) }}
nnoremap <F9> :!%:p
if has("autocmd")
au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw!
au InsertEnter,InsertChange *
\ if v:insertmode == 'i' |
\ silent execute '!echo -ne "\e[6 q"' | redraw! |
\ elseif v:insertmode == 'r' |
\ silent execute '!echo -ne "\e[4 q"' | redraw! |
\ endif
au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
endif
" NERDTree
set wildignore+=*.pyc,*.o,*.obj,*.svn,*.swp,*.class,*.hg,*.DS_Store,*.min.*
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = ''
let g:NERDTreeRespectWildIgnore=1
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nnoremap <silent> <C-b> :NERDTreeToggle<CR>
" Support for end-of-lines
" au BufWritePre * :set binary | set noeol
" au BufWritePost * :set nobinary | set eol
vnoremap <C-a> g<C-a>
vnoremap <C-x> g<C-x>
vnoremap g<C-a> <C-a>
vnoremap g<C-x> <C-x>

17
states/neovim/install.sls Normal file
View File

@ -0,0 +1,17 @@
---
{%- from "neovim/map.jinja" import neovim with context %}
neovim-pkg:
pkg.latest:
- pkgs:
- git
- neovim
neovim-neovimfiles-directory:
file.directory:
- name: {{ neovim.plugins_dir }}
- makedirs: true
neovim-colors-directory:
file.directory:
- name: {{ neovim.colors_dir }}
- makedirs: true

5
states/neovim/map.jinja Normal file
View File

@ -0,0 +1,5 @@
{%- import_yaml "neovim/defaults.yaml" as default_settings -%}
{%- set defaults = salt['grains.filter_by'](default_settings, default='neovim') -%}
{%- set neovim = salt['pillar.get']('neovim', default=defaults, merge=True) -%}

21
states/neovim/plugins.sls Normal file
View File

@ -0,0 +1,21 @@
---
{%- from "neovim/map.jinja" import neovim with context %}
neovim-plugin-git-dep:
pkg.installed:
- pkgs:
- git
- python3-jedi
- yamllint
neovim-plugin-dirs:
file.directory:
- name: {{ neovim.plugins_dir }}
- makedirs: true
{%- for key, value in neovim.plugins.items() %}
neovim-plugin-{{ value.name }}:
git.latest:
- name: {{ value.repo }}
- target: {{ neovim.plugins_dir }}/{{ value.name }}
- submodules: true
{%- endfor %}

15
states/neovim/themes.sls Normal file
View File

@ -0,0 +1,15 @@
---
{%- from "neovim/map.jinja" import neovim with context %}
{%- for key, value in neovim.themes.items() %}
neovim-{{ value.name }}-theme:
file.managed:
- name: {{ neovim.colors_dir }}/{{ value.name }}.vim
- source: {{ value.url }}
- skip_verify: true
- user: root
- group: root
- mode: 0644
- require:
- pkg: neovim-pkg
- file: neovim-colors-directory
{%- endfor %}