add nvim
This commit is contained in:
124
.config/nvim/init.lua
Normal file
124
.config/nvim/init.lua
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
-- ~/.config/nvim/init.lua
|
||||||
|
vim.opt.number = true -- 行番号表示
|
||||||
|
vim.opt.relativenumber = true -- 相対行番号
|
||||||
|
vim.opt.mouse = 'a' -- マウス使える
|
||||||
|
vim.opt.clipboard = 'unnamedplus' -- システムクリップボード
|
||||||
|
|
||||||
|
-- インデント設定
|
||||||
|
vim.opt.tabstop = 2
|
||||||
|
vim.opt.shiftwidth = 2
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
|
||||||
|
-- 検索設定
|
||||||
|
vim.opt.ignorecase = true
|
||||||
|
vim.opt.smartcase = true
|
||||||
|
|
||||||
|
-- vim-plug の設定だよ〜
|
||||||
|
local Plug = vim.fn['plug#']
|
||||||
|
|
||||||
|
vim.call('plug#begin', '~/.local/share/nvim/plugged')
|
||||||
|
|
||||||
|
-- とりあえず最初に入れるといいプラグインたち♪
|
||||||
|
Plug 'nvim-treesitter/nvim-treesitter' -- シンタックスハイライト
|
||||||
|
Plug 'neovim/nvim-lspconfig' -- LSP設定
|
||||||
|
Plug 'hrsh7th/nvim-cmp' -- 補完エンジン
|
||||||
|
Plug 'hrsh7th/cmp-nvim-lsp' -- LSP補完
|
||||||
|
Plug 'hrsh7th/cmp-buffer' -- バッファ補完
|
||||||
|
Plug 'hrsh7th/cmp-path' -- パス補完
|
||||||
|
Plug 'hrsh7th/cmp-cmdline' -- コマンドライン補完
|
||||||
|
Plug 'hrsh7th/cmp-vsnip' -- vsnip補完
|
||||||
|
Plug 'hrsh7th/vim-vsnip' -- vsnipエンジン
|
||||||
|
Plug 'greggh/claude-code.nvim' -- Claude Code integration
|
||||||
|
Plug 'syui/airsave.nvim' -- Auto save plugin
|
||||||
|
|
||||||
|
vim.call('plug#end')
|
||||||
|
|
||||||
|
-- 基本設定
|
||||||
|
vim.opt.number = true
|
||||||
|
vim.opt.relativenumber = true
|
||||||
|
vim.opt.mouse = 'a'
|
||||||
|
vim.opt.clipboard = 'unnamedplus'
|
||||||
|
vim.opt.tabstop = 2
|
||||||
|
vim.opt.shiftwidth = 2
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
vim.opt.ignorecase = true
|
||||||
|
vim.opt.smartcase = true
|
||||||
|
|
||||||
|
-- nvim-cmp の設定(プラグインインストール後に有効化)
|
||||||
|
local ok_cmp, cmp = pcall(require, 'cmp')
|
||||||
|
if ok_cmp then
|
||||||
|
cmp.setup({
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'path' }, -- パス補完を優先
|
||||||
|
{ name = 'buffer' },
|
||||||
|
}),
|
||||||
|
completion = {
|
||||||
|
completeopt = 'menu,menuone,noinsert'
|
||||||
|
},
|
||||||
|
experimental = {
|
||||||
|
ghost_text = true, -- 薄い文字でプレビュー表示
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- コマンドライン補完
|
||||||
|
cmp.setup.cmdline('/', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = 'buffer' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'path' }
|
||||||
|
}, {
|
||||||
|
{ name = 'cmdline' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- airsave.nvim 設定(プラグインインストール後に有効化)
|
||||||
|
local ok_airsave, airsave = pcall(require, 'airsave')
|
||||||
|
if ok_airsave then
|
||||||
|
airsave.setup({
|
||||||
|
auto_write = true, -- g:air_auto_write = 1 と同じ
|
||||||
|
no_silent = true, -- g:air_auto_write_nosilent = 1 と同じ
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 永続undo設定
|
||||||
|
vim.opt.undofile = true
|
||||||
|
vim.opt.undodir = vim.fn.expand('~/.config/nvim/undo')
|
||||||
|
|
||||||
|
-- undo ディレクトリを作成
|
||||||
|
vim.fn.mkdir(vim.fn.expand('~/.config/nvim/undo'), 'p')
|
||||||
|
|
||||||
|
-- ghost textの色設定
|
||||||
|
vim.api.nvim_set_hl(0, 'CmpGhostText', { fg = '#666666', italic = true })
|
||||||
|
|
||||||
|
-- キーマッピング
|
||||||
|
vim.keymap.set('n', 'Q', ':q<CR>', { desc = 'Quit' })
|
||||||
|
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
undo
|
Reference in New Issue
Block a user