Linux
NeoVIM
설치 by appimage
https://github.com/neovim/neovim/releases/ 에서 appimage 다운로드
sudo mv nvim.appimage /usr/local/bin/nvim-0.12.1alias vi='/usr/local/bin/nvim-0.12.1'설정 ~/.config/nvim/init.lua
vim.pack.add {
'https://github.com/nvim-treesitter/nvim-treesitter',
'https://github.com/neovim/nvim-lspconfig',
'https://github.com/stevearc/oil.nvim',
'https://github.com/y9san9/y9nika.nvim',
'https://github.com/brenoprata10/nvim-highlight-colors',
'https://www.github.com/nvim-tree/nvim-tree.lua',
}
vim.cmd.packadd('cfilter')
vim.cmd.packadd('nvim.undotree')
vim.cmd.packadd('nvim.difftool')
vim.g.mapleader = " " -- space for leader
vim.g.maplocalleader = " " -- space for localleader
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.cursorline = true -- highlight current line
vim.opt.wrap = true -- wrap lines by default
vim.opt.tabstop = 2 -- tabwidth
vim.opt.shiftwidth = 2 -- indent width
vim.opt.softtabstop = 2 -- soft tab stop not tabs on tab/backspace
vim.opt.expandtab = true -- use spaces instead of tabs
vim.opt.smartindent = true -- smart auto-indent
vim.opt.autoindent = true -- copy indent from current line
vim.opt.ignorecase = true -- case insensitive search
vim.opt.smartcase = true -- case sensitive if uppercase in string
vim.opt.hlsearch = true -- highlight search matches
vim.opt.incsearch = true -- show matches as you type
vim.opt.colorcolumn = '80'
vim.opt.textwidth = 80
vim.opt.completeopt = 'menu,menuone,fuzzy,noinsert'
vim.opt.swapfile = false
vim.opt.confirm = true
vim.opt.linebreak = true
vim.opt.termguicolors = true
vim.opt.wildoptions:append { 'fuzzy' }
vim.opt.path:append { '**' }
vim.opt.smoothscroll = true
vim.opt.grepprg = 'rg --vimgrep --no-messages --smart-case'
vim.opt.statusline = '[%n] %<%f %h%w%m%r%=%-14.(%l,%c%V%) %P'
-- color scheme
-- vim.cmd.colorscheme('y9nika')
vim.pack.add { { src = "https://github.com/catppuccin/nvim", name = "catppuccin" } }
vim.cmd.colorscheme "catppuccin-nvim"
-- disable mouse popup yet keep mouse enabled
vim.cmd [[
aunmenu PopUp
autocmd! nvim.popupmenu
]]
-- Only highlight with treesitter
-- vim.cmd('syntax off')
require("nvim-highlight-colors").setup {
render = 'virtual',
virtual_symbol = '⚫︎',
virtual_symbol_suffix = '',
}
require('oil').setup {
keymaps = { ['<C-h>'] = false },
columns = { 'size', 'mtime' },
delete_to_trash = true,
skip_confirm_for_simple_edits = true,
}
-- Keymaps
vim.keymap.set('n', '<leader><leader>', ':Oil<CR>', { silent = true })
vim.keymap.set('n', '<leader>a', function()
vim.cmd('$argadd %')
vim.cmd('argdedup')
end)
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Move to left window" })
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Move to bottom window" })
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Move to top window" })
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Move to right window" })
--vim.keymap.set('n', '<C-h>', function() vim.cmd('silent! 1argument') end)
--vim.keymap.set('n', '<C-j>', function() vim.cmd('silent! 2argument') end)
--vim.keymap.set('n', '<C-k>', function() vim.cmd('silent! 3argument') end)
vim.keymap.set('n', '<C-n>', function() vim.cmd('silent! 4argument') end)
vim.keymap.set('n', '<C-m>', function() vim.cmd('silent! 5argument') end)
-- Autocommands
vim.api.nvim_create_autocmd('FileType', {
callback = function() pcall(vim.treesitter.start) end,
})
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
vim.o.signcolumn = 'yes:1'
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
if client:supports_method('textDocument/completion') then
vim.o.complete = 'o,.,w,b,u'
vim.o.completeopt = 'menu,menuone,popup,noinsert'
vim.lsp.completion.enable(true, client.id, args.buf)
end
end
})
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function() vim.highlight.on_yank() end,
})
-- Nvim-Tree
require("nvim-tree").setup({
view = {
width = 20,
},
filters = {
dotfiles = false,
},
renderer = {
group_empty = true,
},
})
vim.keymap.set("n", "<leader>e", function()
require("nvim-tree.api").tree.toggle()
end, { desc = "Toggle NvimTree" })