This commit is contained in:
2022-07-14 21:49:39 +02:00
parent 1379bf56ab
commit 11659a506f
28 changed files with 566 additions and 232 deletions

1
.config/nvim/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
plugin/packer_compiled.lua

View File

@@ -1,59 +0,0 @@
{
"explorer.keyMappings": {
"k": "nodePrev",
"j": "nodeNext",
"*": "toggleSelection",
"<tab>": "actionMenu",
"<Left>": "collapse",
"<Right>": "expand",
"J": ["toggleSelection", "normal:j"],
"K": ["toggleSelection", "normal:k"],
"gl": "expandRecursive",
"gh": "collapseRecursive",
"o": "expandOrCollapse",
"<cr>": "open",
"e": "open",
"E": "openInVsplit",
"t": "openInTab",
"<bs>": "gotoParent",
"y": "copyFilepath",
"Y": "copyFilename",
"c": "copyFile",
"x": "cutFile",
"p": "pasteFile",
"d": "delete",
"D": "deleteForever",
"a": "addFile",
"A": "addDirectory",
"r": "rename",
".": "toggleHidden",
"R": "refresh",
"?": "help",
"q": "quit",
"X": "systemExecute",
"gd": "listDrive",
"f": "search",
"F": "searchRecursive",
"gf": "gotoSource:file",
"gb": "gotoSource:buffer",
"[[": "sourcePrev",
"]]": "sourceNext",
"[d": "diagnosticPrev",
"]d": "diagnosticNext",
"[c": "gitPrev",
"]c": "gitNext",
"<<": "gitStage",
">>": "gitUnstage"
}
}

213
.config/nvim/init.lua Normal file
View File

@@ -0,0 +1,213 @@
require 'plugins'
require 'popup'
vim.g.solarized_italic_comments = true
vim.g.solarized_italic_keywords = true
vim.g.solarized_italic_functions = true
vim.g.solarized_italic_variables = false
vim.g.solarized_contrast = true
vim.g.solarized_borders = false
vim.g.solarized_disable_background = false
require('solarized').set()
require('nvim-treesitter.configs').setup {
ensure_installed = { "c", "lua", "rust", "java", "python", "javascript", "typescript" },
sync_install = false,
ignore_install = { },
highlight = {
enable = true,
disable = { },
additional_vim_regex_highlighting = false,
},
}
require('feline').setup {
theme = require('feline.solarized'),
force_inactive = {
filetypes = {
'^neo\\-tree$',
'^aerial$',
'^packer$',
'^startify$',
'^fugitive$',
'^fugitiveblame$',
'^qf$',
'^help$'
},
buftypes = {
'^terminal$'
},
bufnames = {
'neo\\-.*',
}
}
}
require('nvim-lsp-installer').setup {}
require('lspconfig/settings')
require('window-picker').setup({
autoselect_one = true,
selection_chars = 'ABCDEFGHIJKLMNOP',
filter_rules = {
bo = {
filetype = { 'NvimTree', "neo-tree", "notify", 'aerial' },
buftype = { 'terminal' }
}
}
})
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
require('neo-tree').setup({
close_if_last_window = true,
window = {
width = 30,
mappings = {
["<cr>"] = "open_with_window_picker",
["S"] = "split_with_window_picker",
["s"] = "vsplit_with_window_picker"
}
},
filesystem = {
filtered_items = {
visible = true
},
follow_current_file = true,window = {
mappings = {
["/"] = "noop",
["g/"] = "fuzzy_finder",
["f"] = "noop",
["ff"] = function() vim.cmd([[Telescope find_files]]) end,
["fg"] = function() vim.cmd([[Telescope live_grep]]) end
}
}
}
})
vim.keymap.set("n", "f", "<cmd>Neotree focus<CR>", opts)
require('smart-splits')
vim.keymap.set("n", "<C-Left>", require('smart-splits').move_cursor_left)
vim.keymap.set("n", "<C-Down>", require('smart-splits').move_cursor_down)
vim.keymap.set("n", "<C-Up>", require('smart-splits').move_cursor_up)
vim.keymap.set("n", "<C-Right>", require('smart-splits').move_cursor_right)
vim.keymap.set("n", "<C-S-Up>", require('smart-splits').resize_up)
vim.keymap.set("n", "<C-S-Down>", require('smart-splits').resize_down)
vim.keymap.set("n", "<C-S-Left>", require('smart-splits').resize_left)
vim.keymap.set("n", "<C-S-Right>", require('smart-splits').resize_right)
require('bufdelete')
local colors = require('solarized.colors')
require('bufferline').setup{
options = {
close_command = "Bdelete %d",
right_mouse_command = "Bdelete %d",
offsets = {
{filetype = "neo-tree", text = "File Explorer", padding = 1},
{filetype = "aerial", text = "Outline", padding = 1}
},
enforce_regular_tabs = true,
separator_style = 'slant'
},
highlights = {
separator = {
guifg = colors.bg_alt
},
separator_visible = {
guifg = colors.bg_alt
},
separator_selected = {
guifg = colors.bg_alt
}
}
}
vim.keymap.set("n", "<S-Right>", "<cmd>bnext<CR>", opts)
vim.keymap.set("n", "<S-Left>", "<cmd>bprevious<CR>", opts)
vim.keymap.set("n", "q", "<cmd>Bdelete<CR>", opts)
require('nvim-autopairs').setup()
require('gitsigns').setup()
require('cinnamon').setup()
require('aerial').setup({
close_behavior = 'global',
open_automatic = true,
placement_editor_edge = true,
width = 30,
on_attach = function(bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 't',
require('map_utils').lua_fn(function()
vim.tbl_map(function(buf)
if vim.api.nvim_buf_get_option(buf, 'filetype') == 'aerial' then
vim.tbl_map(function(win)
vim.api.nvim_set_current_win(win)
end, vim.fn.win_findbuf(buf))
end
end, vim.api.nvim_list_bufs())
end),
{})
end
})
require('guess-indent').setup()
local actions = require("telescope.actions")
require('telescope').setup({
defaults = {
mappings = {
n = {
["S"] = actions.file_split,
["s"] = actions.file_vsplit,
}
},
get_selection_window = require('window-picker').pick_window
},
pickers = {
find_files = {
find_command = {"fd", "--type", "f", "--strip-cwd-prefix", "--hidden"}
},
live_grep = {
vimgrep_arguments = {"rg", "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case", "--hidden"}
},
}
})
vim.o.clipboard = 'unnamedplus'
vim.o.expandtab = true
vim.o.fileencoding = 'utf-8'
vim.o.ignorecase = true
vim.o.mouse = 'a'
vim.o.showmode = false
vim.o.number = true
vim.o.shiftwidth = 2
vim.o.signcolumn = 'yes'
vim.o.smartcase = true
vim.o.spelllang = 'en'
vim.o.tabstop = 2
if vim.fn.expand('%') == '' then
require("neo-tree.command")._command(vim.fn.getcwd())
else
require("neo-tree.command")._command("show", vim.fn.getcwd())
end

View File

@@ -1,148 +0,0 @@
tnoremap <Esc> <C-\><C-n>
set termguicolors
"set colorcolumn=88
set background=dark
match Error /\%>88c/
highlight Pmenu ctermbg=gray guibg=gray
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Or use `complete_info` if your vim support it, like:
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Create mappings for function text object, requires document symbols feature of
" languageserver.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
" Use <TAB> for select selections ranges, needs server support, like: coc-tsserver,
" coc-python
nmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select)
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` to fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add status line support, for integration with other plugin, checkout `:h coc-status`
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Using CocList
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" coc-explorer
nmap <leader>e :CocCommand explorer<CR>
call plug#begin()
Plug 'rbgrouleff/bclose.vim'
Plug 'francoiscabrol/ranger.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'lervag/vimtex'
Plug 'iCyMind/NeoSolarized'
call plug#end()
colorscheme NeoSolarized

View File

@@ -0,0 +1,19 @@
local colors = require('solarized.colors')
local solarized = {
fg = colors.fg,
bg = colors.bg_alt,
black = colors.black,
skyblue = colors.paleblue,
cyan = colors.cyan,
green = colors.green,
oceanblue = colors.blue,
magenta = colors.magenta,
orange = colors.orange,
red = colors.red,
violet = colors.purple,
white = colors.white,
yellow = colors.yellow
}
return solarized

View File

@@ -0,0 +1,95 @@
local servers = { 'pyright', 'sumneko_lua', 'eslint', 'tsserver' }
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,
}
}
end
-- luasnip setup
local luasnip = require 'luasnip'
-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}

View File

@@ -0,0 +1,34 @@
local M = {}
local module_name = 'map_utils'
local fn_store = {}
local function register_fn(fn)
table.insert(fn_store, fn)
return #fn_store
end
function M.apply_function(id)
fn_store[id]()
end
function M.apply_expr(id)
return vim.api.nvim_replace_termcodes(fn_store[id](), true, true, true)
end
function M.lua_fn(fn)
return string.format(
"<cmd>lua require('%s').apply_function(%s)<CR>",
module_name,
register_fn(fn)
)
end
function M.lua_expr(fn)
return string.format(
"v:lua.require'%s'.apply_expr(%s)",
module_name,
register_fn(fn)
)
end
return M

View File

@@ -0,0 +1,54 @@
return require('packer').startup(function()
use 'wbthomason/packer.nvim'
use 'nvim-lua/popup.nvim'
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
use {'feline-nvim/feline.nvim', requires = 'kyazdani42/nvim-web-devicons'}
use {
"williamboman/nvim-lsp-installer",
"neovim/nvim-lspconfig",
}
use {
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
requires = {
"nvim-lua/plenary.nvim",
"kyazdani42/nvim-web-devicons",
"MunifTanjim/nui.nvim",
's1n7ax/nvim-window-picker'
}
}
use 'mrjones2014/smart-splits.nvim'
use 'famiu/bufdelete.nvim'
use {'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons'}
use 'windwp/nvim-autopairs'
use 'lewis6991/gitsigns.nvim'
use 'declancm/cinnamon.nvim'
use 'stevearc/aerial.nvim'
use 'nmac427/guess-indent.nvim'
use {'nvim-telescope/telescope.nvim', requires = 'nvim-lua/plenary.nvim'}
use {
'hrsh7th/nvim-cmp',
'hrsh7th/cmp-nvim-lsp',
'saadparwaiz1/cmp_luasnip',
'L3MON4D3/LuaSnip'
}
end)