Skip to content

Commit

Permalink
Drop support for vim; install coc vim as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
danpawlik committed Apr 18, 2024
1 parent a3dd818 commit deb4bb7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 103 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ You can choose the Lsp packages to be installed via plugin manager and press "i"
via Mason:

```shell
:MasonInstall ansible-lint ansible-language-server autotools-language-server bash-language-server checkmake commitlint dhall-lsp dockerfile-language-server gitlint goimports gopls harper-ls helm-ls html-lsp jedi-language-server jinja-lsp jq-lsp json-lsp lua-language-server markdownlint misspell prettier pyright python-lsp-server rstcheck rust-analyzer shellcheck staticcheck systemdlint trivy yaml-language-server yamllint vim-language-server
:MasonInstall ansible-lint ansible-language-server autotools-language-server bash-language-server checkmake commitlint dhall-lsp dockerfile-language-server gitlint goimports gopls harper-ls helm-ls html-lsp jedi-language-server jinja-lsp jq-lsp json-lsp lua-language-server markdownlint misspell prettier pyright python-lsp-server rstcheck ruff ruff-lsp rust-analyzer shellcheck staticcheck systemdlint trivy yaml-language-server yamllint vim-language-server
```

Make sure, that `~/.local/share/nvim/mason/bin/` is set in the PATH.
Expand Down
5 changes: 3 additions & 2 deletions ansible/roles/dotfiles/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ other_fonts:

# available: prezto, starship, oh_my_zsh
zsh_distro: oh_my_zsh

vim_distro: neovim
nvim_version: nightly
nvim_use_coc: false

# it install nodejs into ~/.local/nodejs
# https://nodejs.org/dist/latest-v20.x/
Expand Down Expand Up @@ -223,6 +222,8 @@ mason_packages:
- pyright
- python-lsp-server
- rstcheck
- ruff
- ruff-lsp
- rust-analyzer
- shellcheck
- staticcheck
Expand Down
19 changes: 8 additions & 11 deletions ansible/roles/dotfiles/tasks/lvim.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
---
- name: Install lunar vim
when: vim_distro == 'neovim'
block:
- name: Install required packages
become: true
ansible.builtin.package:
name: cargo
state: present
- name: Install required packages
become: true
ansible.builtin.package:
name: cargo
state: present

- name: Install lunar vim - nightly version
ansible.builtin.shell: |
bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh) -y
- name: Install lunar vim - nightly version
ansible.builtin.shell: |
bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh) -y
154 changes: 65 additions & 89 deletions ansible/roles/dotfiles/tasks/vim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,98 +52,74 @@
path: ~/.config/nvim/autoload
state: directory

- name: Do neovim
when: vim_distro == 'neovim'
block:
- name: Download vim plug
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
dest: ~/.config/nvim/autoload/plug.vim
mode: "0644"

- name: Setup Neovim
include_tasks: neovim.yml

- name: Create symbolic link between vimrc and nvim init
file:
src: ~/.vimrc
dest: ~/.config/nvim/init.vim
state: link

- name: Create symlink to lua dir
ansible.builtin.file:
src: ~/.vim/lua
dest: ~/.config/nvim/lua
state: link
when: vim_distro == 'neovim'

- name: Clone nvim-lspconfig
ansible.builtin.git:
repo: https://github.com/neovim/nvim-lspconfig
dest: /tmp/nvim-lspconfig

- name: Copy lspconfig and lspconfig.lua
ansible.builtin.copy:
src: "/tmp/nvim-lspconfig/lua/{{ item.src }}"
dest: "~/.vim/lua/{{ item.dest }}"
remote_src: true
loop:
- src: lspconfig.lua
dest: lspconfig.lua
- src: lspconfig
dest: lspconfig

- name: Configure vim plugins
environment:
PATH: ~/.local/bin:/usr/local/bin/:{{ ansible_env.PATH }}
block:
- name: Install vim plugins - vim
shell: |
vim +PlugInstall +qall
when: vim_distro == 'vim'

- name: Install vim plugins - neovim
shell: |
# old way: ~/.local/nvim/usr/bin/nvim +PlugInstall +qall
~/.local/nvim/usr/bin/nvim --headless +PlugInstall +qall
when: vim_distro == 'neovim'

- name: Install mason packages
ansible.builtin.shell: |
~/.local/nvim/usr/bin/nvim --headless -c "MasonInstall {{ mason_packages | join(' ') }}" -c qall
- name: Install additional packages for vim
pip:
name:
- types-PyYAML
- types-requests
- pylama
- neovim
- mypy
- pynvim
- rstcheck
- proselint
- gitlint
- ansible-lint
- black
- yapf
- vim-vint
- yamllint
- jedi
- pylint
extra_args: --user
when: pip_packages

- name: Install additional npm packages
become: true
environment:
PATH: ~/.local/bin:/usr/local/bin/:{{ ansible_env.PATH }}
- name: Download vim plug
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
dest: ~/.config/nvim/autoload/plug.vim
mode: "0644"

- name: Setup Neovim
include_tasks: neovim.yml

- name: Create symbolic link between vimrc and nvim init
file:
src: ~/.vimrc
dest: ~/.config/nvim/init.vim
state: link

- name: Create symlink to lua dir
ansible.builtin.file:
src: ~/.vim/lua
dest: ~/.config/nvim/lua
state: link

- name: Clone nvim-lspconfig
ansible.builtin.git:
repo: https://github.com/neovim/nvim-lspconfig
dest: /tmp/nvim-lspconfig

- name: Copy lspconfig and lspconfig.lua
ansible.builtin.copy:
src: "/tmp/nvim-lspconfig/lua/{{ item.src }}"
dest: "~/.vim/lua/{{ item.dest }}"
remote_src: true
loop:
- src: lspconfig.lua
dest: lspconfig.lua
- src: lspconfig
dest: lspconfig

- name: Install neovim plugins
shell: |
npm install -g prettier eslint
~/.local/nvim/usr/bin/nvim --headless +PlugInstall +qall
- name: Install gopls
- name: Install mason packages
when: not nvim_use_coc
ansible.builtin.shell: |
go install golang.org/x/tools/gopls@latest
~/.local/nvim/usr/bin/nvim --headless -c "MasonInstall {{ mason_packages | join(' ') }}" -c qall
- name: Configure vim coc
when: nvim_use_coc
block:
# NOTE: there is no need to comment lua config, when Mason
# packages are not installed.
- name: Enable vim-coc config
ansible.builtin.lineinfile:
path: ~/.vimrc
regexp: '^" source $HOME/.vim/plugin_conf/coc'
line: source $HOME/.vim/plugin_conf/coc

# NOTE: Mason is installing packages in venv or node_modules dir.
# No need to install packages one more time, when it would be not used by vim.
- name: Install additional packages for neovim when coc config set
when: pip_packages
pip:
name: "{{ pip_packages }}"
extra_args: --user --force-reinstall

- name: Install gopls
ansible.builtin.shell: |
go install golang.org/x/tools/gopls@latest
- name: Add PATH to bashrc
lineinfile:
Expand Down

0 comments on commit deb4bb7

Please sign in to comment.