Misc: LSP, Coc, vgit
This commit is contained in:
parent
d35e92f090
commit
ab4cc3e016
60
init.lua
60
init.lua
|
@ -96,6 +96,12 @@ require('config.lspconfig')
|
|||
-- Custom
|
||||
|
||||
Custom = require('config.custom')
|
||||
cmd([[
|
||||
au BufRead,BufNewFile *.ha set filetype=hare
|
||||
au BufRead,BufNewFile *.conf set filetype=config
|
||||
]])
|
||||
|
||||
g["do_filetype_lua"] = 1
|
||||
|
||||
-- Keybinds
|
||||
|
||||
|
@ -105,26 +111,37 @@ local map = Mapper.map
|
|||
|
||||
-- - Telescope-related
|
||||
local opts = { noremap = true, silent = true }
|
||||
map('n', '<Leader>ff', '<cmd>Telescope find_files<cr>', opts, "Telescope", "find_files", "Find files from current position")
|
||||
map('n', '<Leader>ff', '<cmd>Telescope find_files<cr>', opts, "Telescope", "find_files",
|
||||
"Find files from current position")
|
||||
map('n', '<Leader>fg', '<cmd>Telescope git_files<cr>', opts, "Telescope", "git_files", "Find git-tracked files")
|
||||
map('n', '<Leader>fb', '<cmd>Telescope buffers<cr>', opts, "Telescope", "buffers", "Search in current opened buffers")
|
||||
map('n', '<Leader>fc', '<cmd>Telescope grep_string<cr>', opts, "Telescope", "grep_string", "Search string from current position")
|
||||
map('n', '<Leader>fc', '<cmd>Telescope grep_string<cr>', opts, "Telescope", "grep_string",
|
||||
"Search string from current position")
|
||||
map('n', '<Leader>fr', '<cmd>Telescope live_grep<cr>', opts, "Telescope", "live_grep", "Search string in real time")
|
||||
map('n', '<Leader>fR', '<cmd>Telescope live_grep grep_open_files=true<cr>', opts, "Telescope", "live_grep_open_buffers", "Search string in real time (only on the open buffers)")
|
||||
map('n', '<Leader>fR', '<cmd>Telescope live_grep grep_open_files=true<cr>', opts, "Telescope", "live_grep_open_buffers",
|
||||
"Search string in real time (only on the open buffers)")
|
||||
map('n', '<Leader>ft', '<cmd>Telescope treesitter<cr>', opts, "Telescope", "treesitter", "Explore treesitter")
|
||||
map('n', '<Leader>fC', '<cmd>Telescope git_bcommits<cr>', opts, "Telescope", "git_bcommits", "Show diff of current buffer")
|
||||
map('n', '<Leader>fC', '<cmd>Telescope git_bcommits<cr>', opts, "Telescope", "git_bcommits",
|
||||
"Show diff of current buffer")
|
||||
map('n', '<Leader>fh', '<cmd>Telescope builtin<cr>', opts, "Telescope", "builtin", "Show Telescope builtins")
|
||||
map('n', '<Leader>lr', '<cmd>Telescope lsp_references<cr>', opts, "Telescope", "lsp_references", "Show references using LSP")
|
||||
map('n', '<Leader>li', '<cmd>Telescope lsp_implementations<cr>', opts, "Telescope", "lsp_implementations", "Show implementations using LSP")
|
||||
map('n', '<Leader>ld', '<cmd>Telescope lsp_definitions<cr>', opts, "Telescope", "lsp_definitions", "Show definitions using LSP")
|
||||
map('n', '<Leader>ls', '<cmd>Telescope lsp_document_symbols<cr>', opts, "Telescope", "lsp_document_symbols", "Show symbols in document using LSP")
|
||||
map('n', '<Leader>lr', '<cmd>Telescope lsp_references<cr>', opts, "Telescope", "lsp_references",
|
||||
"Show references using LSP")
|
||||
map('n', '<Leader>li', '<cmd>Telescope lsp_implementations<cr>', opts, "Telescope", "lsp_implementations",
|
||||
"Show implementations using LSP")
|
||||
map('n', '<Leader>ld', '<cmd>Telescope lsp_definitions<cr>', opts, "Telescope", "lsp_definitions",
|
||||
"Show definitions using LSP")
|
||||
map('n', '<Leader>ls', '<cmd>Telescope lsp_document_symbols<cr>', opts, "Telescope", "lsp_document_symbols",
|
||||
"Show symbols in document using LSP")
|
||||
|
||||
-- Undo tree
|
||||
map('n', '<Leader>u', '<cmd>UndotreeToggle<cr><cmd>UndotreeFocus<cr>', { noremap = true }, "UndoTree", "undo_tree_toggle", "Toggle UndoTree browser")
|
||||
map('n', '<Leader>u', '<cmd>UndotreeToggle<cr><cmd>UndotreeFocus<cr>', { noremap = true }, "UndoTree", "undo_tree_toggle"
|
||||
, "Toggle UndoTree browser")
|
||||
|
||||
-- Split maximizer
|
||||
map('n', '<Leader>mm', '<cmd>MaximizerToggle<cr>', opts, "MaximizerToggle", "maximizer_toggle_n", "Toggle maximal view of current split")
|
||||
map('v', '<Leader>mm', '<cmd>MaximizerToggle<cr>', opts, "MaximizerToggle", "maximizer_toggle_v", "Toggle maximal view of current split")
|
||||
map('n', '<Leader>mm', '<cmd>MaximizerToggle<cr>', opts, "MaximizerToggle", "maximizer_toggle_n",
|
||||
"Toggle maximal view of current split")
|
||||
map('v', '<Leader>mm', '<cmd>MaximizerToggle<cr>', opts, "MaximizerToggle", "maximizer_toggle_v",
|
||||
"Toggle maximal view of current split")
|
||||
|
||||
-- Split movement and management
|
||||
map('n', '<C-l>', '<C-w>l', opts, "Movement", "move_right_n", "Move to the split to the right")
|
||||
|
@ -150,6 +167,11 @@ map('i', '<C-d>', '<cmd>bd<cr>', opts, "Management", "full_close_i", "Close curr
|
|||
map('n', '<Leader><Tab>', '<cmd>bnext<cr>', {}, "Movement", "go_to_next_buf", "Switch to the next buffer")
|
||||
map('n', '<Leader>\\', '<cmd>bprev<cr>', {}, "Movement", "go_to_prev_buf", "Switch to the previous buffer")
|
||||
|
||||
-- Search niceties
|
||||
|
||||
map('v', '<Leader>/', '<esc>:\\%V', {}, "Search", "search_in_visual_selection",
|
||||
"Search only in the current visual selection")
|
||||
|
||||
-- Move selection around
|
||||
cmd([[
|
||||
nnoremap <silent> <C-Down> :m .+1<CR>==
|
||||
|
@ -167,7 +189,19 @@ vnoremap <silent> <C-Up> :m '<-2<CR>gv=gv
|
|||
-- map('v', '<C-Up>', "<cmd>m '<-2<CR>gv=gv", opst, "MoveText", "move_text_down_v", "")
|
||||
|
||||
-- Clean highlight
|
||||
map('n', '<leader><esc>', '<cmd>nohls<CR><cmd>call clearmatches()<cr>', opts, "CleanHighlights", "clear_all", "Clear all highlights and matches")
|
||||
map('n', '<leader><esc>', '<cmd>nohls<CR><cmd>call clearmatches()<cr>', opts, "CleanHighlights", "clear_all",
|
||||
"Clear all highlights and matches")
|
||||
|
||||
-- Open links with reader
|
||||
map('n', 'gx', '<cmd>lua Custom.open_with_reader()<cr>', {}, "OpenWithReader", "open_with_reader", "Open the link under the cursor with `reader` in a floating tab")
|
||||
map('n', 'gx', '<cmd>lua Custom.open_with_reader()<cr>', {}, "OpenWithReader", "open_with_reader",
|
||||
"Open the link under the cursor with `reader` in a floating tab")
|
||||
|
||||
-- cder
|
||||
map('n', '<leader>cd', '<cmd>Telescope cder<cr>', {}, "Cder", "cder", "Change base directory interactively")
|
||||
|
||||
-- vgit
|
||||
|
||||
require('config.vgit')
|
||||
|
||||
-- coc
|
||||
require('config.coc')
|
||||
|
|
35
lua/config/coc.lua
Normal file
35
lua/config/coc.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
-- Some servers have issues with backup files, see #649.
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
|
||||
-- Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||
-- delays and poor user experience.
|
||||
vim.opt.updatetime = 300
|
||||
|
||||
-- Always show the signcolumn, otherwise it would shift the text each time
|
||||
-- diagnostics appear/become resolved.
|
||||
vim.opt.signcolumn = "yes"
|
||||
|
||||
|
||||
-- Auto complete
|
||||
function _G.check_back_space()
|
||||
local col = vim.fn.col('.') - 1
|
||||
return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s')
|
||||
end
|
||||
|
||||
local opts = { silent = true, noremap = true, expr = true }
|
||||
|
||||
-- Use tab for trigger completion with characters ahead and navigate.
|
||||
-- NOTE: There's always complete item selected by default, you may want to enable
|
||||
-- no select by `"suggest.noselect": true` in your configuration file.
|
||||
-- NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||
-- other plugin before putting this into your config.
|
||||
-- vim.api.nvim_set_keymap("i", "<TAB>",
|
||||
-- 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "<TAB>" : coc#refresh()', opts)
|
||||
-- vim.api.nvim_set_keymap("i", "<S-TAB>",
|
||||
-- [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]], opts)
|
||||
|
||||
-- Make <CR> to accept selected completion item or notify coc.nvim to format
|
||||
-- <C-g>u breaks current undo, please make your own choice.
|
||||
vim.api.nvim_set_keymap("i", "<cr>",
|
||||
[[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"]], opts)
|
|
@ -18,34 +18,46 @@ end
|
|||
|
||||
-- nvim_lsp.harepls.setup {}
|
||||
|
||||
-- keybindings
|
||||
|
||||
local on_attach = function(client, bufrn)
|
||||
Mapper = require("nvim-mapper")
|
||||
local function buf_set_keymap(...) Mapper.map_buf(bufrn, ...) end
|
||||
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufrn, ...) end
|
||||
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings
|
||||
local opts = { noremap=true, silent=true }
|
||||
-- Mappings
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts, "LSP", "declaration", "Go to declaration")
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts, "LSP", "definition", "Go to definition")
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts, "LSP", "hover", "Hover")
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts, "LSP", "implementation", "Go to implementation")
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts, "LSP", "signature_help", "Show signature help")
|
||||
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts, "LSP", "add_workspace_folder", "Add workspace folder")
|
||||
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts, "LSP", "remove_workspace_folder", "Remove workspace folder")
|
||||
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts, "LSP", "list_workspace_folders", "List workspace folder")
|
||||
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts, "LSP", "type_definition", "Show type definition")
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts, "LSP", "rename", "Rename")
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts, "LSP", "code_action", "Show code actions")
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts, "LSP", "references", "Show references")
|
||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts, "LSP", "show_line_diagnostics", "Show line diagnostic")
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts, "LSP", "goto_prev", "Go to previous")
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts, "LSP", "goto_next", "Go to next")
|
||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts, "LSP", "set_loclist", "Set loclist")
|
||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts, "LSP", "formatting", "Format")
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts, "LSP", "declaration", "Go to declaration")
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts, "LSP", "definition", "Go to definition")
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts, "LSP", "hover", "Hover")
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts, "LSP", "implementation",
|
||||
"Go to implementation")
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts, "LSP", "signature_help",
|
||||
"Show signature help")
|
||||
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts, "LSP",
|
||||
"add_workspace_folder", "Add workspace folder")
|
||||
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts, "LSP",
|
||||
"remove_workspace_folder", "Remove workspace folder")
|
||||
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts, "LSP"
|
||||
, "list_workspace_folders", "List workspace folder")
|
||||
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts, "LSP", "type_definition",
|
||||
"Show type definition")
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts, "LSP", "rename", "Rename")
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts, "LSP", "code_action",
|
||||
"Show code actions")
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts, "LSP", "references", "Show references")
|
||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts, "LSP",
|
||||
"show_line_diagnostics", "Show line diagnostic")
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts, "LSP", "goto_prev", "Go to previous")
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts, "LSP", "goto_next", "Go to next")
|
||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts, "LSP", "set_loclist",
|
||||
"Set loclist")
|
||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts, "LSP", "formatting", "Format")
|
||||
end
|
||||
|
||||
-- Launch language servers
|
||||
|
@ -63,57 +75,72 @@ local servers = {
|
|||
'zls',
|
||||
}
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
require'lspconfig'.jsonls.setup {
|
||||
cmd = { "vscode-json-languageserver", "--stdio" },
|
||||
capabilities = capabilities,
|
||||
commands = {
|
||||
Format = {
|
||||
function()
|
||||
vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})
|
||||
end
|
||||
require 'lspconfig'.jsonls.setup {
|
||||
cmd = { "vscode-json-languageserver", "--stdio" },
|
||||
capabilities = capabilities,
|
||||
commands = {
|
||||
Format = {
|
||||
function()
|
||||
vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line("$"), 0 })
|
||||
end
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
require'lspconfig'.sumneko_lua.setup {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = {'vim'},
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
require 'lspconfig'.sumneko_lua.setup {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { 'vim' },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- lsp_lines
|
||||
require('lsp_lines').setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
})
|
||||
|
||||
vim.keymap.set(
|
||||
"",
|
||||
"<space>l",
|
||||
require("lsp_lines").toggle,
|
||||
{ desc = "Toggle lsp_lines" }
|
||||
)
|
||||
|
||||
|
||||
-- Format on save
|
||||
vim.cmd [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()]]
|
||||
|
|
216
lua/config/vgit.lua
Normal file
216
lua/config/vgit.lua
Normal file
|
@ -0,0 +1,216 @@
|
|||
vim.o.updatetime = 300
|
||||
vim.o.incsearch = false
|
||||
vim.wo.signcolumn = 'yes'
|
||||
|
||||
require('vgit').setup({
|
||||
keymaps = {
|
||||
['n <leader>gk'] = 'hunk_up',
|
||||
['n <leader>gj'] = 'hunk_down',
|
||||
['n <leader>gs'] = 'buffer_hunk_stage',
|
||||
['n <leader>gr'] = 'buffer_hunk_reset',
|
||||
['n <leader>gp'] = 'buffer_hunk_preview',
|
||||
['n <leader>gb'] = 'buffer_blame_preview',
|
||||
['n <leader>gf'] = 'buffer_diff_preview',
|
||||
['n <leader>gh'] = 'buffer_history_preview',
|
||||
['n <leader>gu'] = 'buffer_reset',
|
||||
['n <leader>gg'] = 'buffer_gutter_blame_preview',
|
||||
['n <leader>glu'] = 'project_hunks_preview',
|
||||
['n <leader>gls'] = 'project_hunks_staged_preview',
|
||||
['n <leader>gd'] = 'project_diff_preview',
|
||||
['n <leader>gq'] = 'project_hunks_qf',
|
||||
['n <leader>gx'] = 'toggle_diff_preference',
|
||||
},
|
||||
settings = {
|
||||
-- git = {
|
||||
-- cmd = 'git', -- optional setting, not really required
|
||||
-- fallback_cwd = vim.fn.expand("$HOME"),
|
||||
-- fallback_args = {
|
||||
-- "--git-dir",
|
||||
-- vim.fn.expand("$HOME/dots/yadm-repo"),
|
||||
-- "--work-tree",
|
||||
-- vim.fn.expand("$HOME"),
|
||||
-- },
|
||||
-- },
|
||||
hls = {
|
||||
GitBackground = 'Normal',
|
||||
GitHeader = 'NormalFloat',
|
||||
GitFooter = 'NormalFloat',
|
||||
GitBorder = 'LineNr',
|
||||
GitLineNr = 'LineNr',
|
||||
GitComment = 'Comment',
|
||||
GitSignsAdd = {
|
||||
gui = nil,
|
||||
fg = '#d7ffaf',
|
||||
bg = nil,
|
||||
sp = nil,
|
||||
override = false,
|
||||
},
|
||||
GitSignsChange = {
|
||||
gui = nil,
|
||||
fg = '#7AA6DA',
|
||||
bg = nil,
|
||||
sp = nil,
|
||||
override = false,
|
||||
},
|
||||
GitSignsDelete = {
|
||||
gui = nil,
|
||||
fg = '#e95678',
|
||||
bg = nil,
|
||||
sp = nil,
|
||||
override = false,
|
||||
},
|
||||
GitSignsAddLn = 'DiffAdd',
|
||||
GitSignsDeleteLn = 'DiffDelete',
|
||||
GitWordAdd = {
|
||||
gui = nil,
|
||||
fg = nil,
|
||||
bg = '#5d7a22',
|
||||
sp = nil,
|
||||
override = false,
|
||||
},
|
||||
GitWordDelete = {
|
||||
gui = nil,
|
||||
fg = nil,
|
||||
bg = '#960f3d',
|
||||
sp = nil,
|
||||
override = false,
|
||||
},
|
||||
},
|
||||
live_blame = {
|
||||
enabled = true,
|
||||
format = function(blame, git_config)
|
||||
local config_author = git_config['user.name']
|
||||
local author = blame.author
|
||||
if config_author == author then
|
||||
author = 'You'
|
||||
end
|
||||
local time = os.difftime(os.time(), blame.author_time)
|
||||
/ (60 * 60 * 24 * 30 * 12)
|
||||
local time_divisions = {
|
||||
{ 1, 'years' },
|
||||
{ 12, 'months' },
|
||||
{ 30, 'days' },
|
||||
{ 24, 'hours' },
|
||||
{ 60, 'minutes' },
|
||||
{ 60, 'seconds' },
|
||||
}
|
||||
local counter = 1
|
||||
local time_division = time_divisions[counter]
|
||||
local time_boundary = time_division[1]
|
||||
local time_postfix = time_division[2]
|
||||
while time < 1 and counter ~= #time_divisions do
|
||||
time_division = time_divisions[counter]
|
||||
time_boundary = time_division[1]
|
||||
time_postfix = time_division[2]
|
||||
time = time * time_boundary
|
||||
counter = counter + 1
|
||||
end
|
||||
local commit_message = blame.commit_message
|
||||
if not blame.committed then
|
||||
author = 'You'
|
||||
commit_message = 'Uncommitted changes'
|
||||
return string.format(' %s • %s', author, commit_message)
|
||||
end
|
||||
local max_commit_message_length = 255
|
||||
if #commit_message > max_commit_message_length then
|
||||
commit_message = commit_message:sub(1, max_commit_message_length) .. '...'
|
||||
end
|
||||
return string.format(
|
||||
' %s, %s • %s',
|
||||
author,
|
||||
string.format(
|
||||
'%s %s ago',
|
||||
time >= 0 and math.floor(time + 0.5) or math.ceil(time - 0.5),
|
||||
time_postfix
|
||||
),
|
||||
commit_message
|
||||
)
|
||||
end,
|
||||
},
|
||||
live_gutter = {
|
||||
enabled = true,
|
||||
edge_navigation = true, -- This allows users to navigate within a hunk
|
||||
},
|
||||
authorship_code_lens = {
|
||||
enabled = true,
|
||||
},
|
||||
scene = {
|
||||
diff_preference = 'unified',
|
||||
},
|
||||
diff_preview = {
|
||||
keymaps = {
|
||||
buffer_stage = 'S',
|
||||
buffer_unstage = 'U',
|
||||
buffer_hunk_stage = 's',
|
||||
buffer_hunk_unstage = 'u',
|
||||
toggle_view = 't',
|
||||
},
|
||||
},
|
||||
project_diff_preview = {
|
||||
keymaps = {
|
||||
buffer_stage = 's',
|
||||
buffer_unstage = 'u',
|
||||
buffer_hunk_stage = 'gs',
|
||||
buffer_hunk_unstage = 'gu',
|
||||
buffer_reset = 'r',
|
||||
stage_all = 'S',
|
||||
unstage_all = 'U',
|
||||
reset_all = 'R',
|
||||
},
|
||||
},
|
||||
signs = {
|
||||
priority = 10,
|
||||
definitions = {
|
||||
GitSignsAddLn = {
|
||||
linehl = 'GitSignsAddLn',
|
||||
texthl = nil,
|
||||
numhl = nil,
|
||||
icon = nil,
|
||||
text = '',
|
||||
},
|
||||
GitSignsDeleteLn = {
|
||||
linehl = 'GitSignsDeleteLn',
|
||||
texthl = nil,
|
||||
numhl = nil,
|
||||
icon = nil,
|
||||
text = '',
|
||||
},
|
||||
GitSignsAdd = {
|
||||
texthl = 'GitSignsAdd',
|
||||
numhl = nil,
|
||||
icon = nil,
|
||||
linehl = nil,
|
||||
text = '┃',
|
||||
},
|
||||
GitSignsDelete = {
|
||||
texthl = 'GitSignsDelete',
|
||||
numhl = nil,
|
||||
icon = nil,
|
||||
linehl = nil,
|
||||
text = '┃',
|
||||
},
|
||||
GitSignsChange = {
|
||||
texthl = 'GitSignsChange',
|
||||
numhl = nil,
|
||||
icon = nil,
|
||||
linehl = nil,
|
||||
text = '┃',
|
||||
},
|
||||
},
|
||||
usage = {
|
||||
screen = {
|
||||
add = 'GitSignsAddLn',
|
||||
remove = 'GitSignsDeleteLn',
|
||||
},
|
||||
main = {
|
||||
add = 'GitSignsAdd',
|
||||
remove = 'GitSignsDelete',
|
||||
change = 'GitSignsChange',
|
||||
},
|
||||
},
|
||||
},
|
||||
symbols = {
|
||||
void = '⣿',
|
||||
},
|
||||
}
|
||||
})
|
|
@ -24,7 +24,10 @@ local function init()
|
|||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = { { 'nvim-lua/popup.nvim' }, { 'nvim-lua/plenary.nvim' } },
|
||||
config = function() require("telescope").load_extension("mapper") end
|
||||
config = function()
|
||||
require("telescope").load_extension("mapper");
|
||||
require("telescope").load_extension('cder');
|
||||
end
|
||||
}
|
||||
|
||||
-- Highlight
|
||||
|
@ -67,6 +70,11 @@ local function init()
|
|||
|
||||
-- LSP stuff
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'https://git.sr.ht/~whynothugo/lsp_lines.nvim'
|
||||
-- -- Coq
|
||||
use {'ms-jpq/coq_nvim', branch = 'coq'}
|
||||
use {'ms-jpq/coq.artifacts', branch = 'artifacts'}
|
||||
use {'ms-jpq/coq.thirdparty', branch = '3p'}
|
||||
|
||||
-- Split maximizer
|
||||
use 'szw/vim-maximizer'
|
||||
|
@ -85,6 +93,20 @@ local function init()
|
|||
|
||||
-- Autotag completer
|
||||
use 'windwp/nvim-ts-autotag'
|
||||
|
||||
-- cder.nvim
|
||||
use 'zane-/cder.nvim'
|
||||
|
||||
-- dressing.nvim
|
||||
use 'stevearc/dressing.nvim'
|
||||
|
||||
-- vgit
|
||||
use {
|
||||
'tanvirtin/vgit.nvim',
|
||||
requires = {
|
||||
'nvim-lua/plenary.nvim'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
local plugins = setmetatable({}, {
|
||||
|
|
|
@ -9,22 +9,25 @@ vim.api.nvim_command('packadd packer.nvim')
|
|||
|
||||
local no_errors, error_msg = pcall(function()
|
||||
|
||||
local time
|
||||
local profile_info
|
||||
local should_profile = false
|
||||
if should_profile then
|
||||
local hrtime = vim.loop.hrtime
|
||||
profile_info = {}
|
||||
time = function(chunk, start)
|
||||
if start then
|
||||
profile_info[chunk] = hrtime()
|
||||
else
|
||||
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
|
||||
end
|
||||
_G._packer = _G._packer or {}
|
||||
_G._packer.inside_compile = true
|
||||
|
||||
local time
|
||||
local profile_info
|
||||
local should_profile = false
|
||||
if should_profile then
|
||||
local hrtime = vim.loop.hrtime
|
||||
profile_info = {}
|
||||
time = function(chunk, start)
|
||||
if start then
|
||||
profile_info[chunk] = hrtime()
|
||||
else
|
||||
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
|
||||
end
|
||||
else
|
||||
time = function(chunk, start) end
|
||||
end
|
||||
else
|
||||
time = function(chunk, start) end
|
||||
end
|
||||
|
||||
local function save_profiles(threshold)
|
||||
local sorted_times = {}
|
||||
|
@ -38,8 +41,10 @@ local function save_profiles(threshold)
|
|||
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
|
||||
end
|
||||
end
|
||||
if threshold then
|
||||
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
|
||||
end
|
||||
|
||||
_G._packer = _G._packer or {}
|
||||
_G._packer.profile_output = results
|
||||
end
|
||||
|
||||
|
@ -79,11 +84,36 @@ _G.packer_plugins = {
|
|||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/black",
|
||||
url = "https://github.com/psf/black"
|
||||
},
|
||||
["cder.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/cder.nvim",
|
||||
url = "https://github.com/zane-/cder.nvim"
|
||||
},
|
||||
["coc.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/coc.nvim",
|
||||
url = "https://github.com/neoclide/coc.nvim"
|
||||
},
|
||||
["coq.artifacts"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/coq.artifacts",
|
||||
url = "https://github.com/ms-jpq/coq.artifacts"
|
||||
},
|
||||
coq_nvim = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/coq_nvim",
|
||||
url = "https://github.com/ms-jpq/coq_nvim"
|
||||
},
|
||||
["dressing.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/dressing.nvim",
|
||||
url = "https://github.com/stevearc/dressing.nvim"
|
||||
},
|
||||
["lsp_lines.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/lsp_lines.nvim",
|
||||
url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim"
|
||||
},
|
||||
["lualine.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/lualine.nvim",
|
||||
|
@ -131,8 +161,9 @@ _G.packer_plugins = {
|
|||
url = "https://github.com/windwp/nvim-ts-autotag"
|
||||
},
|
||||
["nvim-web-devicons"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons",
|
||||
url = "https://github.com/kyazdani42/nvim-web-devicons"
|
||||
},
|
||||
["packer.nvim"] = {
|
||||
|
@ -151,7 +182,7 @@ _G.packer_plugins = {
|
|||
url = "https://github.com/nvim-lua/popup.nvim"
|
||||
},
|
||||
["telescope.nvim"] = {
|
||||
config = { "\27LJ\2\nK\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\1K\0\1\0\vmapper\19load_extension\14telescope\frequire\0" },
|
||||
config = { "\27LJ\2\nh\0\0\3\0\5\0\r6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\0016\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\4\0B\0\2\1K\0\1\0\tcder\vmapper\19load_extension\14telescope\frequire\0" },
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/telescope.nvim",
|
||||
url = "https://github.com/nvim-telescope/telescope.nvim"
|
||||
|
@ -161,6 +192,11 @@ _G.packer_plugins = {
|
|||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/undotree",
|
||||
url = "https://github.com/mbbill/undotree"
|
||||
},
|
||||
["vgit.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/vgit.nvim",
|
||||
url = "https://github.com/tanvirtin/vgit.nvim"
|
||||
},
|
||||
["vim-matchup"] = {
|
||||
loaded = true,
|
||||
path = "/home/leo/.local/share/nvim/site/pack/packer/start/vim-matchup",
|
||||
|
@ -181,12 +217,19 @@ _G.packer_plugins = {
|
|||
time([[Defining packer_plugins]], false)
|
||||
-- Config for: telescope.nvim
|
||||
time([[Config for telescope.nvim]], true)
|
||||
try_loadstring("\27LJ\2\nK\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\1K\0\1\0\vmapper\19load_extension\14telescope\frequire\0", "config", "telescope.nvim")
|
||||
try_loadstring("\27LJ\2\nh\0\0\3\0\5\0\r6\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\3\0B\0\2\0016\0\0\0'\2\1\0B\0\2\0029\0\2\0'\2\4\0B\0\2\1K\0\1\0\tcder\vmapper\19load_extension\14telescope\frequire\0", "config", "telescope.nvim")
|
||||
time([[Config for telescope.nvim]], false)
|
||||
-- Config for: nvim-mapper
|
||||
time([[Config for nvim-mapper]], true)
|
||||
try_loadstring("\27LJ\2\n=\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\16nvim-mapper\frequire\0", "config", "nvim-mapper")
|
||||
time([[Config for nvim-mapper]], false)
|
||||
|
||||
_G._packer.inside_compile = false
|
||||
if _G._packer.needs_bufread == true then
|
||||
vim.cmd("doautocmd BufRead")
|
||||
end
|
||||
_G._packer.needs_bufread = false
|
||||
|
||||
if should_profile then save_profiles() end
|
||||
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue
Block a user