From 3691c68cc52b8751c20f486450f63187e3a6342d Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 14 May 2022 11:23:16 +0200 Subject: [PATCH] added neovim state --- states/neovim/config.sls | 12 +++++ states/neovim/defaults.yaml | 89 +++++++++++++++++++++++++++++++++++++ states/neovim/init.sls | 6 +++ states/neovim/init.vim.j2 | 53 ++++++++++++++++++++++ states/neovim/install.sls | 17 +++++++ states/neovim/map.jinja | 5 +++ states/neovim/plugins.sls | 21 +++++++++ states/neovim/themes.sls | 15 +++++++ 8 files changed, 218 insertions(+) create mode 100644 states/neovim/config.sls create mode 100644 states/neovim/defaults.yaml create mode 100644 states/neovim/init.sls create mode 100644 states/neovim/init.vim.j2 create mode 100644 states/neovim/install.sls create mode 100644 states/neovim/map.jinja create mode 100644 states/neovim/plugins.sls create mode 100644 states/neovim/themes.sls diff --git a/states/neovim/config.sls b/states/neovim/config.sls new file mode 100644 index 0000000..f4cd343 --- /dev/null +++ b/states/neovim/config.sls @@ -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 \ No newline at end of file diff --git a/states/neovim/defaults.yaml b/states/neovim/defaults.yaml new file mode 100644 index 0000000..8af6e1e --- /dev/null +++ b/states/neovim/defaults.yaml @@ -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: "" + 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: {} diff --git a/states/neovim/init.sls b/states/neovim/init.sls new file mode 100644 index 0000000..26b777b --- /dev/null +++ b/states/neovim/init.sls @@ -0,0 +1,6 @@ +--- +include: + - .install + - .config + - .plugins + - .themes \ No newline at end of file diff --git a/states/neovim/init.vim.j2 b/states/neovim/init.vim.j2 new file mode 100644 index 0000000..7824d88 --- /dev/null +++ b/states/neovim/init.vim.j2 @@ -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 :!%: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 :NERDTreeToggle + +" Support for end-of-lines +" au BufWritePre * :set binary | set noeol +" au BufWritePost * :set nobinary | set eol + +vnoremap g +vnoremap g +vnoremap g +vnoremap g \ No newline at end of file diff --git a/states/neovim/install.sls b/states/neovim/install.sls new file mode 100644 index 0000000..da3e78e --- /dev/null +++ b/states/neovim/install.sls @@ -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 \ No newline at end of file diff --git a/states/neovim/map.jinja b/states/neovim/map.jinja new file mode 100644 index 0000000..2ee2e5e --- /dev/null +++ b/states/neovim/map.jinja @@ -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) -%} \ No newline at end of file diff --git a/states/neovim/plugins.sls b/states/neovim/plugins.sls new file mode 100644 index 0000000..047174d --- /dev/null +++ b/states/neovim/plugins.sls @@ -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 %} diff --git a/states/neovim/themes.sls b/states/neovim/themes.sls new file mode 100644 index 0000000..b4de4ee --- /dev/null +++ b/states/neovim/themes.sls @@ -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 %} \ No newline at end of file