Compare commits
7 Commits
20d8ddf906
...
431566d260
Author | SHA1 | Date | |
---|---|---|---|
|
431566d260 | ||
|
5762d37163 | ||
|
8f9a26b5ce | ||
|
565e336cb8 | ||
|
9535194a33 | ||
|
7c1ab65e48 | ||
|
e4a676d7c8 |
18
nvimrc
18
nvimrc
@ -105,7 +105,7 @@ augroup vimrc
|
|||||||
" https://github.com/fatih/vim-go/issues/1757#issuecomment-565130503
|
" https://github.com/fatih/vim-go/issues/1757#issuecomment-565130503
|
||||||
autocmd FileType qf if (getwininfo(win_getid())[0].loclist != 1) | wincmd J | endif
|
autocmd FileType qf if (getwininfo(win_getid())[0].loclist != 1) | wincmd J | endif
|
||||||
" Remove trailing whitespace pre-save:
|
" Remove trailing whitespace pre-save:
|
||||||
autocmd FileType go,ruby,markdown,rust,python,markdown,lua autocmd BufWritePre <buffer> silent! %s/\s\+$//e
|
autocmd FileType go,ruby,markdown,rust,python,markdown,lua,sql autocmd BufWritePre <buffer> silent! %s/\s\+$//e
|
||||||
augroup end
|
augroup end
|
||||||
|
|
||||||
" Don't remember the current directory for a given file:
|
" Don't remember the current directory for a given file:
|
||||||
@ -126,6 +126,8 @@ imap <left> <nop>
|
|||||||
imap <right> <nop>
|
imap <right> <nop>
|
||||||
nmap ]q :cn<cr>
|
nmap ]q :cn<cr>
|
||||||
nmap [q :cp<cr>
|
nmap [q :cp<cr>
|
||||||
|
nmap + ]
|
||||||
|
nmap ` [
|
||||||
|
|
||||||
nnoremap <silent> <leader>w :up<cr>
|
nnoremap <silent> <leader>w :up<cr>
|
||||||
nnoremap <silent> <leader>/ :nohlsearch<cr>
|
nnoremap <silent> <leader>/ :nohlsearch<cr>
|
||||||
@ -180,7 +182,6 @@ endfunction
|
|||||||
nnoremap <leader>as :Git<cr>
|
nnoremap <leader>as :Git<cr>
|
||||||
nnoremap <leader>ab :Git blame<cr>
|
nnoremap <leader>ab :Git blame<cr>
|
||||||
nnoremap <leader>ac :Commits<cr>
|
nnoremap <leader>ac :Commits<cr>
|
||||||
nnoremap <leader>ah :GitGutterLineHighlightsToggle<cr>
|
|
||||||
nnoremap <leader>aY :call CopyGitURLToLineOrRange()<cr>
|
nnoremap <leader>aY :call CopyGitURLToLineOrRange()<cr>
|
||||||
vnoremap <leader>aY :call CopyGitURLToLineOrRange()<cr>
|
vnoremap <leader>aY :call CopyGitURLToLineOrRange()<cr>
|
||||||
nnoremap <leader>ao :call OpenGitURLToLineOrRange()<cr>
|
nnoremap <leader>ao :call OpenGitURLToLineOrRange()<cr>
|
||||||
@ -240,15 +241,10 @@ packadd! nvim-web-devicons " https://github.com/nvim-tree/nvim-web-devicons.git
|
|||||||
|
|
||||||
lua require "lightline_config"
|
lua require "lightline_config"
|
||||||
|
|
||||||
" vim-gitgutter configuration
|
" gitsigns.nvim
|
||||||
packadd! vim-gitgutter " https://github.com/airblade/vim-gitgutter.git
|
packadd! gitsigns.nvim " https://github.com/lewis6991/gitsigns.nvim.git
|
||||||
set signcolumn=yes
|
|
||||||
nmap ]h <Plug>(GitGutterNextHunk)
|
lua require "gitsigns_config"
|
||||||
nmap [h <Plug>(GitGutterPrevHunk)
|
|
||||||
omap ih <Plug>(GitGutterTextObjectInnerPending)
|
|
||||||
omap ah <Plug>(GitGutterTextObjectOuterPending)
|
|
||||||
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
|
|
||||||
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
|
|
||||||
|
|
||||||
" enable inline vim highlighting:
|
" enable inline vim highlighting:
|
||||||
let g:vimsyn_embed= 'lPr'
|
let g:vimsyn_embed= 'lPr'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local prettier = function()
|
local prettier = function()
|
||||||
return {
|
return {
|
||||||
exe = Get_project_node_modules_path() .. "/.bin/prettier",
|
exe = vim.fn.getcwd() .. "/node_modules/.bin/prettier",
|
||||||
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
|
args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0), "--single-quote" },
|
||||||
stdin = true,
|
stdin = true,
|
||||||
}
|
}
|
||||||
|
93
vim/lua/gitsigns_config.lua
Normal file
93
vim/lua/gitsigns_config.lua
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
require("gitsigns").setup({
|
||||||
|
signs = {
|
||||||
|
add = { text = "│" },
|
||||||
|
change = { text = "~" },
|
||||||
|
delete = { text = "_" },
|
||||||
|
topdelete = { text = "‾" },
|
||||||
|
changedelete = { text = "%" },
|
||||||
|
untracked = { text = "┆" },
|
||||||
|
},
|
||||||
|
signcolumn = true,
|
||||||
|
numhl = false,
|
||||||
|
linehl = false,
|
||||||
|
word_diff = false,
|
||||||
|
watch_gitdir = {
|
||||||
|
follow_files = true,
|
||||||
|
},
|
||||||
|
attach_to_untracked = true,
|
||||||
|
current_line_blame = true,
|
||||||
|
current_line_blame_opts = {
|
||||||
|
virt_text = true,
|
||||||
|
virt_text_pos = "eol",
|
||||||
|
delay = 1000,
|
||||||
|
ignore_whitespace = false,
|
||||||
|
},
|
||||||
|
current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>",
|
||||||
|
sign_priority = 6,
|
||||||
|
update_debounce = 100,
|
||||||
|
status_formatter = nil,
|
||||||
|
max_file_length = 40000,
|
||||||
|
preview_config = {
|
||||||
|
border = "single",
|
||||||
|
style = "minimal",
|
||||||
|
relative = "cursor",
|
||||||
|
row = 0,
|
||||||
|
col = 1,
|
||||||
|
},
|
||||||
|
yadm = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
local gs = package.loaded.gitsigns
|
||||||
|
|
||||||
|
local function map(mode, l, r, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.buffer = bufnr
|
||||||
|
vim.keymap.set(mode, l, r, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
map("n", "]h", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "]h"
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.next_hunk()
|
||||||
|
end)
|
||||||
|
return "<Ignore>"
|
||||||
|
end, { expr = true })
|
||||||
|
|
||||||
|
map("n", "[h", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "[h"
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.prev_hunk()
|
||||||
|
end)
|
||||||
|
return "<Ignore>"
|
||||||
|
end, { expr = true })
|
||||||
|
|
||||||
|
map("n", "<leader>hs", gs.stage_hunk)
|
||||||
|
map("n", "<leader>hr", gs.reset_hunk)
|
||||||
|
map("v", "<leader>hs", function()
|
||||||
|
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||||
|
end)
|
||||||
|
map("v", "<leader>hr", function()
|
||||||
|
gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||||
|
end)
|
||||||
|
map("n", "<leader>hS", gs.stage_buffer)
|
||||||
|
map("n", "<leader>hu", gs.undo_stage_hunk)
|
||||||
|
map("n", "<leader>hR", gs.reset_buffer)
|
||||||
|
map("n", "<leader>hp", gs.preview_hunk)
|
||||||
|
map("n", "<leader>hb", function()
|
||||||
|
gs.blame_line({ full = true })
|
||||||
|
end)
|
||||||
|
map("n", "<leader>tb", gs.toggle_current_line_blame)
|
||||||
|
map("n", "<leader>hd", gs.diffthis)
|
||||||
|
map("n", "<leader>hD", function()
|
||||||
|
gs.diffthis("~")
|
||||||
|
end)
|
||||||
|
map("n", "<leader>td", gs.toggle_deleted)
|
||||||
|
|
||||||
|
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
|
||||||
|
end,
|
||||||
|
})
|
@ -1,16 +1,3 @@
|
|||||||
-- Return the node_modules path for this project. If the project root contains a
|
|
||||||
-- frontend/ directory, assume node_modules lives there.
|
|
||||||
function Get_project_node_modules_path()
|
|
||||||
local root_path = vim.fn.getcwd()
|
|
||||||
local frontend_path = root_path .. "/frontend"
|
|
||||||
local is_frontend = vim.fn.isdirectory(frontend_path) ~= 0
|
|
||||||
local base_path = root_path
|
|
||||||
if is_frontend then
|
|
||||||
base_path = frontend_path
|
|
||||||
end
|
|
||||||
return base_path .. "/node_modules"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Return the project's go module path from go.mod, or an empty string if the file cannot be read.
|
-- Return the project's go module path from go.mod, or an empty string if the file cannot be read.
|
||||||
function Get_project_go_module_path()
|
function Get_project_go_module_path()
|
||||||
local root_path = vim.fn.getcwd()
|
local root_path = vim.fn.getcwd()
|
||||||
|
@ -66,7 +66,7 @@ require("lualine").setup({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_y = { { "progress", padding = { left = 1, right = 0 } } },
|
lualine_y = { { "progress", padding = { left = 1, right = 0 } } },
|
||||||
lualine_z = { { "location", padding = { left = 1, right = 0 } } },
|
lualine_z = { { "location", padding = { left = 1, right = 1 } } },
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
lualine_a = {},
|
lualine_a = {},
|
||||||
|
@ -57,6 +57,7 @@ nvim_lsp.gopls.setup({
|
|||||||
-- Disalbing linksInHover may not be working as expected:
|
-- Disalbing linksInHover may not be working as expected:
|
||||||
linksInHover = false,
|
linksInHover = false,
|
||||||
usePlaceholders = true,
|
usePlaceholders = true,
|
||||||
|
experimentalPostfixCompletions = true,
|
||||||
analyses = {
|
analyses = {
|
||||||
unusedparams = true,
|
unusedparams = true,
|
||||||
shadow = true,
|
shadow = true,
|
||||||
@ -66,6 +67,9 @@ nvim_lsp.gopls.setup({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
init_options = {
|
||||||
|
usePlaceholders = true,
|
||||||
|
},
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
})
|
})
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
-- local cmp_buffer = require("cmp_buffer")
|
-- local cmp_buffer = require("cmp_buffer")
|
||||||
|
|
||||||
|
local has_words_before = function()
|
||||||
|
unpack = unpack or table.unpack
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
completion = {
|
completion = {
|
||||||
completeopt = "menu,menuone,noselect",
|
completeopt = "menu,menuone,noinsert,noselect",
|
||||||
},
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user