Created
January 4, 2022 10:10
-
-
Save sunaemon/67f0291ac5ff6d8b5942dab09e97c730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] | |
require('plugins') | |
vim.cmd [[filetype plugin indent on]] | |
vim.cmd [[syntax enable]] | |
-- display setting | |
vim.o.list = true -- show tab trail etc... | |
vim.o.listchars = 'tab:» ,trail:_,extends:>,precedes:<' -- specify how them displayed | |
vim.o.wildmode = 'list:full' | |
-- cursor move | |
vim.o.whichwrap = 'b,s,h,l,<,>,[,]' | |
vim.o.scrolloff = 3 | |
vim.o.statusline = '%F%m%r%h%w [FORMAT=%{&ff}] [TYPE=%Y] [ASCII=%03.3b] [HEX=%02.2B] [POS=%04l,%04v][%p%%] [LEN=%L]' | |
-- search | |
vim.o.hlsearch =true -- hilight found strings | |
vim.o.smartcase = true | |
vim.o.gdefault = true -- enable 'g' by default on replacement | |
vim.o.incsearch = true | |
vim.o.helpheight = 999 -- show help in full screen | |
-- remove hilight with two esc | |
vim.cmd [[nnoremap <silent> <ESC><ESC> :nohlsearch<CR>]] | |
vim.o.hidden = true -- dont warn on move from unsaved buffer | |
vim.o.wrap = true | |
vim.o.backup = false | |
-- tab setting | |
vim.o.autoindent = true | |
vim.o.expandtab = true -- expand tab -> space | |
vim.o.smartindent = true | |
vim.o.autowrite = true -- automatically write file | |
vim.o.undofile = true | |
vim.o.undodir = vim.fn.stdpath('data') .. '/undo' | |
vim.o.showmode = true -- show current mode | |
vim.o.mouse = 'a' | |
vim.o.autoread= true | |
vim.o.completeopt = 'menuone,noinsert' | |
vim.cmd [[ | |
nnoremap Q <Nop> | |
nnoremap ZZ <Nop> | |
nnoremap ZQ <Nop> | |
noremap : ; | |
noremap ; : | |
let mapleader = "\<Space>" | |
]] | |
-- highlight | |
vim.cmd [[ | |
nnoremap <leader>cc :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> | |
colorscheme default | |
highlight Comment ctermfg=6 | |
highlight Constant ctermfg=3 | |
highlight Identifier ctermfg=6 | |
highlight Statement ctermfg=3 | |
highlight PreProc ctermfg=5 | |
highlight Special ctermfg=5 | |
highlight Type ctermfg=2 | |
highlight Underlined cterm=underline ctermfg=5 | |
highlight Error cterm=bold ctermfg=7 ctermbg=1 | |
highlight Title ctermfg=5 | |
highlight Pmenu ctermfg=0 ctermbg=2 | |
highlight PmenuSel ctermfg=7 ctermbg=0 | |
highlight PmenuSbar ctermbg=7 | |
highlight PmenuThumb ctermbg=2 | |
highlight DiffAdd cterm=none ctermfg=2 ctermbg=none | |
highlight DiffDelete cterm=none ctermfg=1 ctermbg=none | |
highlight DiffChange cterm=none ctermfg=3 ctermbg=none | |
highlight DiffText cterm=bold ctermfg=1 ctermbg=none | |
highlight link LspDiagnosticsDefaultUnderline Underlined | |
highlight link LspDiagnosticsDefaultHint Underlined | |
highlight link LspDiagnosticsDefaultError Error | |
highlight link LspDiagnosticsDefaultWarning Error | |
highlight link LspDiagnosticsDefaultInformation Error | |
function! FullWidthSpace() | |
highlight FullWidthSpace cterm=reverse ctermfg=DarkMagenta gui=reverse guifg=DarkMagenta | |
endfunction | |
augroup FullWidthSpace | |
autocmd! | |
autocmd ColorScheme * call FullWidthSpace() | |
autocmd VimEnter,WinEnter * match FullWidthSpace / / | |
augroup end | |
call FullWidthSpace() | |
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local install_path = vim.fn.stdpath('data') .. | |
'/site/pack/packer/start/packer.nvim' | |
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then | |
packer_bootstrap = vim.fn.system({ | |
'git', 'clone', '--depth', '1', | |
'https://github.com/wbthomason/packer.nvim', install_path | |
}) | |
end | |
vim.cmd [[packadd packer.nvim]] | |
return require('packer').startup(function(use) | |
use 'wbthomason/packer.nvim' | |
-- clever f | |
use { | |
'rhysd/clever-f.vim', | |
config = function() | |
vim.api.nvim_set_keymap('n', '[denite]', '<Nop>', {noremap = true}) | |
vim.api.nvim_set_keymap('n', ',', '<Nop>', {noremap = true}) | |
vim.api.nvim_set_keymap('n', ',', '[denite]', {}) | |
end | |
} | |
-- s... to move easy | |
-- thanks to clever f, we can use s for easy motion | |
use { | |
'easymotion/vim-easymotion', | |
config = function() | |
vim.api.nvim_set_keymap('n', 's', '<Nop>', {noremap = true}) | |
vim.api.nvim_set_keymap('n', 's', '<Plug>(easymotion-s2)', {}) | |
vim.api.nvim_set_var('EasyMotion_smartcase', 1) | |
end | |
} | |
use { | |
'Shougo/denite.nvim', | |
config = function() | |
vim.api.nvim_set_keymap('n', '[denite]b', | |
':<C-u>Denite -split=no buffer<CR>', | |
{noremap = true, silent = true}) | |
vim.api.nvim_set_keymap('n', '[denite]r', | |
':<C-u>Denite register<CR>', | |
{noremap = true, silent = true}) | |
vim.api.nvim_set_keymap('n', '[denite]g', ':<C-u>Denite grep<CR>', | |
{noremap = true, silent = true}) | |
vim.api.nvim_set_keymap('n', '[denite]p', | |
':<C-u>Denite -resume<CR>', | |
{noremap = true, silent = true}) | |
vim.fn['denite#custom#var']('file/rec', 'command', | |
{'rg', '--files', '--glob', '!.git'}) | |
vim.fn['denite#custom#var']('grep', 'command', {'rg'}) | |
vim.fn['denite#custom#var']('grep', 'default_opts', | |
{'-i', '--vimgrep', '--no-heading'}) | |
vim.fn['denite#custom#var']('grep', 'recursive_opts', {}) | |
vim.fn['denite#custom#var']('grep', 'pattern_opt', {'--regexp'}) | |
vim.fn['denite#custom#var']('grep', 'separator', {'--'}) | |
vim.fn['denite#custom#var']('grep', 'final_opts', {}) | |
function _G.denite_my_settings() | |
local function nbemap(key, cmd) | |
vim.api.nvim_buf_set_keymap(0, 'n', key, cmd, {noremap = true, silent = true, expr = true}) | |
end | |
nbemap('<CR>', "denite#do_map('do_action')") | |
nbemap('d', "denite#do_map('do_action', 'delete')") | |
nbemap('p', "denite#do_map('do_action', 'preview')") | |
nbemap('q', "denite#do_map('quit')") | |
nbemap('i', "denite#do_map('open_filter_buffer')") | |
nbemap('<Space>', "denite#do_map('toggle_select').'j'") | |
end | |
vim.cmd [[autocmd FileType denite lua denite_my_settings()]] | |
end | |
} | |
use { | |
'Shougo/neomru.vim', | |
config = function() | |
vim.api.nvim_set_keymap('n', '[denite]c', | |
':<C-u>Denite -split=no file_mru<CR>', | |
{noremap = true, silent = true}) | |
end | |
} | |
use { | |
'Shougo/neoyank.vim', | |
config = function() | |
vim.api.nvim_set_keymap('n', '[denite]y', | |
':<C-u>Denite neoyank<CR>', | |
{noremap = true, silent = true}) | |
end | |
} | |
use { | |
'Shougo/defx.nvim', | |
config = function() | |
function string.starts(String, Start) | |
return string.sub(String, 1, string.len(Start)) == Start | |
end | |
function denite_open_current_file() | |
if string.starts(vim.fn.expand('%'), 'term://') then | |
vim.api.nvim_command('Defx') | |
else | |
vim.api.nvim_command( | |
'Defx ' .. vim.fn.expand('%:p:h') .. ' -search=' .. | |
vim.fn.expand('%:p')) | |
end | |
end | |
vim.api.nvim_set_keymap('n', '[denite]f', | |
'<cmd>lua denite_open_current_file()<CR>', | |
{noremap = true, silent = true}) | |
vim.api.nvim_set_keymap('n', '[denite]F', ':<C-u>Defx<CR>', | |
{noremap = true, silent = true}) | |
function _G.defx_my_settings() | |
local function nbemap(key, cmd) | |
vim.api.nvim_buf_set_keymap(0, 'n', key, cmd, {noremap = true, silent = true, expr = true}) | |
end | |
nbemap('<CR>', "defx#do_action('open')") | |
nbemap('c', "defx#do_action('copy')") | |
nbemap('m', "defx#do_action('move')") | |
nbemap('p', "defx#do_action('paste')") | |
nbemap('l', "defx#do_action('open')") | |
nbemap('E', "defx#do_action('open', 'vsplit')") | |
nbemap('o', "defx#do_action('open_tree', 'toggle')") | |
nbemap('K', "defx#do_action('new_directory')") | |
nbemap('N', "defx#do_action('new_file')") | |
nbemap('M', "defx#do_action('new_multiple_files')") | |
nbemap('C', "defx#do_action('toggle_columns', 'mark:indent:icon:filename:type:size:time')") | |
nbemap('S', "defx#do_action('toggle_sort', 'time')") | |
nbemap('d', "defx#do_action('remove')") | |
nbemap('r', "defx#do_action('rename')") | |
nbemap('!', "defx#do_action('execute_command')") | |
nbemap('x', "defx#do_action('execute_system')") | |
nbemap('yy', "defx#do_action('yank_path')") | |
nbemap('.', "defx#do_action('toggle_ignored_files')") | |
nbemap(';', "defx#do_action('repeat')") | |
nbemap('h', "defx#do_action('cd', ['..'])") | |
nbemap('~', "defx#do_action('cd')") | |
nbemap('q', "defx#do_action('quit')") | |
nbemap('<Space>', "defx#do_action('toggle_select') . 'j'") | |
nbemap('*', "defx#do_action('toggle_select_all')") | |
nbemap('j', "line('.') == line('$') ? 'gg' : 'j'") | |
nbemap('k', "line('.') == 1 ? 'G' : 'k'") | |
nbemap('<C-l>', "defx#do_action('redraw')") | |
nbemap('<C-g>', "defx#do_action('print')") | |
nbemap('cd', "defx#do_action('change_vim_cwd')") | |
end | |
vim.cmd [[autocmd FileType defx lua defx_my_settings()]] | |
end | |
} | |
-- ys, cd, ds | |
use 'rhysd/vim-operator-surround' | |
-- [b etc | |
use 'tpope/vim-unimpaired' | |
-- replace with _ | |
use { | |
'kana/vim-operator-replace', | |
config = function() vim.api.nvim_set_keymap('', '_', '<Plug>(operator-replace)', {silent = true}) end, | |
requires = {{'kana/vim-operator-user'}} | |
} | |
-- comment out with gc | |
use 'tyru/caw.vim' | |
use 'tpope/vim-repeat' | |
use { | |
'lambdalisue/suda.vim', | |
config = function() vim.cmd [[command! W :SudaWrite]] end | |
} | |
-- A Git wrapper | |
use 'tpope/vim-fugitive' | |
-- A Vim plugin which shows a git diff in the gutter (sign column) and stages/undoes hunks. | |
use 'airblade/vim-gitgutter' | |
-- BD | |
use { | |
'qpkorr/vim-bufkill', | |
config = function() | |
vim.cmd [[cabbrev bd <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'BD' : 'bd')<CR>]] | |
end | |
} | |
use { | |
'hotwatermorning/auto-git-diff', | |
config = function() | |
function _G.setup_auto_git_diff() | |
vim.api.nvim_buf_set_keymap(0, 'n', '<C-l>', | |
"<Plug>(auto_git_diff_scroll_manual_update)", | |
{noremap = true, silent = true}) | |
vim.api.nvim_buf_set_keymap(0, 'n', '<C-n>', | |
"<Plug>(auto_git_diff_scroll_down_half)", | |
{noremap = true, silent = true}) | |
vim.api.nvim_buf_set_keymap(0, 'n', '<C-p>', | |
"<Plug>(auto_git_diff_scroll_up_half)", | |
{noremap = true, silent = true}) | |
vim.cmd [[autocmd FileType gitrebase lua setup_auto_git_diff()]] | |
end | |
setup_auto_git_diff() | |
end | |
} | |
use 'editorconfig/editorconfig-vim' | |
use 'dag/vim-fish' | |
use 'tyru/capture.vim' | |
-- % | |
use 'tmhedberg/matchit' | |
use {'neovim/nvim-lspconfig', | |
config = function() | |
local capabilities = require('cmp_nvim_lsp').update_capabilities( | |
vim.lsp.protocol.make_client_capabilities()) | |
local nvim_lsp = require('lspconfig') | |
require('lspconfig.configs')['satysfi'] = { | |
default_config = { | |
cmd = {'satysfi-language-server'}, | |
filetypes = {'satysfi'}, | |
root_dir = require('lspconfig.util').find_git_ancestor, | |
single_file_support = true, | |
log_level = vim.lsp.protocol.MessageType.Log, | |
message_level = vim.lsp.protocol.MessageType.Log | |
}, | |
docs = {description = ''} | |
} | |
local on_attach = function(client, bufnr) | |
local function buf_set_keymap(key, cmd) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', key, '<cmd>lua ' .. cmd .. '<CR>', {noremap = true, silent = true}) | |
end | |
buf_set_keymap('gD', 'vim.lsp.buf.declaration()') | |
buf_set_keymap('gd', 'vim.lsp.buf.definition()') | |
buf_set_keymap('K', 'vim.lsp.buf.hover()') | |
buf_set_keymap('gi', 'vim.lsp.buf.implementation()') | |
buf_set_keymap('<C-k>', 'vim.lsp.buf.signature_help()') | |
buf_set_keymap('<space>wa', 'vim.lsp.buf.add_workspace_folder()') | |
buf_set_keymap('<space>wr', 'vim.lsp.buf.remove_workspace_folder()') | |
buf_set_keymap('<space>wl', 'print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') | |
buf_set_keymap('<space>D', 'vim.lsp.buf.type_definition()') | |
buf_set_keymap('<space>rn', 'vim.lsp.buf.rename()') | |
buf_set_keymap('<space>ca', 'vim.lsp.buf.code_action()') | |
buf_set_keymap('gr', 'vim.lsp.buf.references()') | |
buf_set_keymap('<space>e', 'vim.diagnostic.open_float()') | |
buf_set_keymap('[d', 'vim.diagnostic.goto_prev()') | |
buf_set_keymap(']d', 'vim.diagnostic.goto_next()') | |
buf_set_keymap('<space>q', 'vim.diagnostic.setloclist()') | |
buf_set_keymap('<space>f', 'vim.lsp.buf.formatting()') | |
end | |
-- local servers = {'clangd', 'pylsp', 'satysfi'} | |
local servers = {'clangd', 'pylsp'} | |
for _, lsp in ipairs(servers) do | |
nvim_lsp[lsp].setup { | |
on_attach = on_attach, | |
capabilities = capabilities, | |
flags = {debounce_text_changes = 150} | |
} | |
end | |
end, | |
requires = {{'hrsh7th/cmp-nvim-lsp'}} | |
} | |
use 'hrsh7th/cmp-vsnip' | |
use 'hrsh7th/vim-vsnip' | |
use 'hrsh7th/cmp-nvim-lsp' | |
use 'hrsh7th/cmp-buffer' | |
use 'hrsh7th/cmp-path' | |
use 'hrsh7th/cmp-cmdline' | |
use { | |
'hrsh7th/nvim-cmp', | |
config = function() | |
local cmp = require 'cmp' | |
cmp.setup({ | |
snippet = { | |
expand = function(args) | |
vim.fn["vsnip#anonymous"](args.body) | |
end | |
}, | |
mapping = { | |
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), | |
{'i', 'c'}), | |
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), | |
{'i', 'c'}), | |
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), | |
{'i', 'c'}), | |
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. | |
['<C-e>'] = cmp.mapping({ | |
i = cmp.mapping.abort(), | |
c = cmp.mapping.close() | |
}), | |
['<CR>'] = cmp.mapping.confirm({select = true}) -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | |
}, | |
sources = cmp.config.sources({ | |
{name = 'nvim_lsp'}, {name = 'vsnip'} | |
}, {{name = 'buffer'}}) | |
}) | |
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). | |
cmp.setup.cmdline('/', {sources = {{name = 'buffer'}}}) | |
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). | |
cmp.setup.cmdline(':', { | |
sources = cmp.config | |
.sources({{name = 'path'}}, {{name = 'cmdline'}}) | |
}) | |
end | |
} | |
use { | |
'nvim-lualine/lualine.nvim', | |
requires = { 'kyazdani42/nvim-web-devicons'}, | |
config = function() | |
require('lualine').setup{ options = { theme = require('lualine.themes.solarized_dark')} } | |
end | |
} | |
use 'qnighy/satysfi.vim' | |
if packer_bootstrap then require('packer').sync() end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment