본문 바로가기
Programming/환경셋팅

neo-vim 설치 - CoC, Python - 실시간자동완성 적용

by Chan_찬 2023. 5. 27.
728x90

vi를 IDE 처럼 사용해보자

설치

brew install nvim
brew install cmake
brew install luarocks
brew install pkg-config

nodeJs 설치

#mac 
brew install node@18
brew unlink node
brew link --overwrite node@18

#linux 
curl -sL install-node.now.sh/lts | sudo bash #linux

yarn 설치

#mac
brew install yarn 

#linux
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

vim plugin 설치

curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

pip3 install --user pynvim

neovim / coc.nvim

mkdir -p ~/.config/nvim
nvim ~/.config/nvim/init.vim

init.vim config 파일

아래 사이트에서 config 파일 다운 받아서 사용
https://raw.githubusercontent.com/fisadev/fisa-vim-config/v12.0.1/config.vim

다운받은 파일 마지막에 아래 내용들 추가

...

"----------------------------------------------------------------------------------
"-- plugins
"----------------------------------------------------------------------------------
call plug#begin('~/.config/nvim/plugged')

" Use release branch
Plug 'neoclide/coc.nvim', {'branch': 'release'}

" Or latest tag
Plug 'neoclide/coc.nvim', {'tag': '*', 'branch': 'release'}

" Or build from source code by use yarn: https://yarnpkg.com
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}

" tabnine
"Plug 'aca/completion-tabnine', { 'do': './install.sh' }
Plug 'codota/tabnine-nvim', { 'do': './dl_binaries.sh' 
call plug#end()


"----------------------------------------------------------------------------------
"-- plugin config
"----------------------------------------------------------------------------------
" tabnin vimrc
let g:completion_chain_complete_list = {
    \ 'default': [
    \    {'complete_items': ['lsp', 'snippet', 'tabnine' ]},
    \    {'mode': '<c-p>'},
    \    {'mode': '<c-n>'}
    \]
\}

플러그인 설치

nvim +PlugInstall

coc 환경 파일 생성

nvim +CocConfig
{
  "codeLens.enable": true,
  "diagnostic.errorSign": "✖",
  "diagnostic.hintSign": "➤",
  "diagnostic.infoSign": "ℹ",
  "diagnostic.warningSign": "⚠",
  "eslint.autoFixOnSave": true,
  "languageserver": {
    "ccls": {
      "command": "ccls",
      "filetypes": [
        "c",
        "cpp",
        "objc",
        "objcpp"
      ],
      "initializationOptions": {
        "cache": {
          "directory": "/tmp/ccls"
        }
      },
      "rootPatterns": [
        ".ccls",
        ".git/",
        ".hg/",
        ".vim/",
        "compile_commands.json"
      ]
    },
    "golang": {
      "command": "gopls",
      "filetypes": [
        "go"
      ],
      "rootPatterns": [
        ".git/",
        ".hg/",
        ".vim/",
        "go.mod"
      ]
    },
    "python": {
      "args": [
        "--log-file",
        "-mpyls",
        "-vv",
        "/tmp/lsp_python.log"
      ],
      "command": "python",
      "filetypes": [
        "python"
      ],
      "settings": {
        "pyls": {
          "commandPath": "",
          "configurationSources": [
            "pycodestyle"
          ],
          "enable": true,
          "plugins": {
            "jedi_completion": {
              "enabled": true
            },
            "jedi_hover": {
              "enabled": true
            },
            "jedi_references": {
              "enabled": true
            },
            "jedi_signature_help": {
              "enabled": true
            },
            "jedi_symbols": {
              "all_scopes": true,
              "enabled": true
            },
            "mccabe": {
              "enabled": true,
              "threshold": 15
            },
            "preload": {
              "enabled": true
            },
            "pycodestyle": {
              "enabled": true
            },
            "pydocstyle": {
              "enabled": false,
              "match": "(?!test_).*\\.py",
              "matchDir": "[^\\.].*"
            },
            "pyflakes": {
              "enabled": true
            },
            "rope_completion": {
              "enabled": true
            },
            "yapf": {
              "enabled": true
            }
          },
          "trace": {
            "server": "verbose"
          }
        }
      },
      "trace.server": "verbose"
    }
  },
  "python.jediEnabled": false,
  "python.linting.pylintArgs": [
    "--load-plugins",
    "pylint_django"
  ],
  "python.linting.pylintEnabled": true,
  "python.venvFolders": [
    ".direnv",
    ".pyenv",
    "envs",
    "~/.cache/pypoetry/virtualenvs",
    "~/.local/share/virtualenvs"
  ],
  "python.workspaceSymbols.exclusionPatterns": [],
  "signature.enable": true,
  "suggest.echodocSupport": true,
  "suggest.noselect": false,
  "suggest.preferCompleteThanJumpPlaceholder": true,
  "tsserver.implicitProjectConfig.experimentalDecorators": true
}

nvim plugin 설치

nvim 에 접속한 상태로 아래 커맨드 입력으로 플러그인 설치

:CocInstall coc-python
:CocInstall coc-pyright
:CocInstall coc-tabnine
:CocInstall coc-json

 

coc.vim 에러경우

cd ~/.config/nvim/plugged/coc.vim
yarn install
yarn build
728x90
728x90
Buy me a coffeeBuy me a coffee

댓글