diff --git a/README.md b/README.md index 6c801c8..4d9e6e4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/ansible/roles/dotfiles/defaults/main.yml b/ansible/roles/dotfiles/defaults/main.yml index 25c2c48..3dc2f8b 100644 --- a/ansible/roles/dotfiles/defaults/main.yml +++ b/ansible/roles/dotfiles/defaults/main.yml @@ -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/ @@ -223,6 +222,8 @@ mason_packages: - pyright - python-lsp-server - rstcheck + - ruff + - ruff-lsp - rust-analyzer - shellcheck - staticcheck diff --git a/ansible/roles/dotfiles/tasks/lvim.yml b/ansible/roles/dotfiles/tasks/lvim.yml index d7782dd..639c5b9 100644 --- a/ansible/roles/dotfiles/tasks/lvim.yml +++ b/ansible/roles/dotfiles/tasks/lvim.yml @@ -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 diff --git a/ansible/roles/dotfiles/tasks/vim.yml b/ansible/roles/dotfiles/tasks/vim.yml index 02dc0cf..7bfb963 100644 --- a/ansible/roles/dotfiles/tasks/vim.yml +++ b/ansible/roles/dotfiles/tasks/vim.yml @@ -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: