반응형
현재 쓰고있는 RockyLinux8 (RHEL8) 에서 쓸수 있는 nvim 은 0.10.4 이고,
여기에는 유명한 플러그인 lazyvim 은 쓸수 없어서 순정에 어울리는 vim-plug 로 셋팅을 했다.
1. nvim 은 컴파일 설치 ( 이전 글 참조! )
https://taisou.tistory.com/1095
로컬개발 환경 - Rocky Linux 8.10 ( WSL2 ) 구성
폐쇄망 리눅스 RHEL8.10 을 위한?로컬 개발 환경 구성 방법 # 1. 패키지 저장소 업데이트 및 필수 저장소 활성화dnf update -ydnf install -y epel-releasednf config-manager --set-enabled powertools# 2. [중요] Zsh 쉘 설치 (
taisou.tistory.com
2. 플러그인 설치 ( for node.js )
# 기존 셋팅은 과감히 삭제
rm ~/.config/nvim/init.lua
# 설정파일 오픈
nano ~/.config/nvim/init.lua
# vim-plugin 설치
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
예전 vim 을 설정하듯이 설정!
-- ~/.config/nvim/init.lua
-----------------------------------------------------------
-- 1. 기본 설정 (여기는 오류가 안 납니다)
-----------------------------------------------------------
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.mouse = "a"
vim.opt.clipboard = "unnamedplus"
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.termguicolors = true
vim.opt.signcolumn = "yes"
vim.g.mapleader = " "
-----------------------------------------------------------
-- 2. 플러그인 목록 (vim-plug)
-----------------------------------------------------------
local Plug = vim.fn['plug#']
vim.call('plug#begin')
-- 테마
Plug('ellisonleao/gruvbox.nvim')
-- 문법 강조 (Next.js/TSX 필수)
Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'})
-- 자동완성 (Node.js 기반)
Plug('neoclide/coc.nvim', {['branch'] = 'release'})
vim.call('plug#end')
-----------------------------------------------------------
-- 3. 플러그인 설정 (안전장치 적용: pcall 사용)
-----------------------------------------------------------
-- [안전장치 1] 테마 설정
-- 테마가 없으면 기본 색상 유지 (에러 방지)
pcall(vim.cmd, "colorscheme gruvbox")
-- [안전장치 2] Treesitter (문법 강조) 설정
-- 플러그인이 설치되어 있을 때만 실행
local status_ts, ts_configs = pcall(require, "nvim-treesitter.configs")
if status_ts then
ts_configs.setup {
ensure_installed = { "typescript", "tsx", "javascript", "json", "html", "css" },
highlight = { enable = true },
indent = { enable = true },
}
end
-- [안전장치 3] COC.nvim (자동완성) 설정
-- COC는 별도 require 없이 vim script 방식으로 동작하므로 키맵만 설정
local keyset = vim.keymap.set
function _G.check_back_space()
local col = vim.fn.col('.') - 1
return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil
end
-- 탭(Tab)으로 자동완성 이동 (가장 중요한 설정)
local opts = {silent = true, noremap = true, expr = true, replace_keycodes = false}
keyset("i", "<TAB>", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "<TAB>" : coc#refresh()', opts)
keyset("i", "<S-TAB>", [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]], opts)
-- 엔터(Enter)로 선택
keyset("i", "<CR>", [[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"]], opts)
-- gd 로 정의 이동, K 로 문서 보기
keyset("n", "gd", "<Plug>(coc-definition)", {silent = true})
keyset("n", "K", "call CocActionAsync('doHover')", {silent = true})
nvim 실행 후,
:PlugInstall
설치 완료 되면 , q 한 후 아래로 설치
:CocInstall coc-tsserver coc-json coc-html coc-css coc-prettier coc-eslint
q 나가면 완료!
반응형