Some nvim changes

This commit is contained in:
Nise Void 2023-12-07 10:27:09 +01:00
parent 06cbd8fba9
commit de99674c49
2 changed files with 72 additions and 36 deletions

View File

@ -352,7 +352,7 @@ function! plug#end()
endif
let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
if exists('g:did_load_filetypes')
if get(g:, 'did_load_filetypes', 0)
filetype off
endif
for name in g:plugs_order
@ -2621,26 +2621,34 @@ function! s:preview_commit()
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
if empty(sha)
return
let name = matchstr(getline('.'), '^- \zs[^:]*\ze:$')
if empty(name)
return
endif
let title = 'HEAD@{1}..'
let command = 'git diff --no-color HEAD@{1}'
else
let title = sha
let command = 'git show --no-color --pretty=medium '.sha
let name = s:find_name(line('.'))
endif
let name = s:find_name(line('.'))
if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
return
endif
if exists('g:plug_pwindow') && !s:is_preview_window_open()
execute g:plug_pwindow
execute 'e' sha
execute 'e' title
else
execute 'pedit' sha
execute 'pedit' title
wincmd P
endif
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command
if s:is_win
let [batchfile, cmd] = s:batchfile(cmd)
endif
@ -2766,9 +2774,9 @@ function! s:snapshot(force, ...) abort
1
let anchor = line('$') - 3
let names = sort(keys(filter(copy(g:plugs),
\'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)')))
\'has_key(v:val, "uri") && isdirectory(v:val.dir)')))
for name in reverse(names)
let sha = s:git_revision(g:plugs[name].dir)
let sha = has_key(g:plugs[name], 'commit') ? g:plugs[name].commit : s:git_revision(g:plugs[name].dir)
if !empty(sha)
call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
redraw

View File

@ -11,12 +11,12 @@ call plug#begin()
" UI
Plug 'ctrlpvim/ctrlp.vim'
"Plug 'Shougo/echodoc.vim'
" Formatting helpers
Plug 'tpope/vim-commentary'
" Language specific
Plug 'neovim/nvim-lspconfig'
Plug 'fatih/vim-go'
Plug 'exu/pgsql.vim'
@ -105,11 +105,9 @@ let g:cm_sources_override = {
au FileType go nmap <F11> :GoAlternate<CR>
" Go
let g:go_fmt_command = "gofumports"
let g:go_fmt_command = "gofumpt"
let g:go_fmt_fail_silently = 1
" let g:go_gocode_unimported_packages = 0
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_types = 1
@ -120,45 +118,75 @@ let g:go_highlight_build_constraints = 1
let g:go_highlight_generate_tags = 1
let g:go_metalinter_autosave = 0
" let g:go_metalinter_autosave_enabled = ['golint', 'ineffassign']
let g:go_template_autocreate = 0
" let g:go_auto_type_info=1
" let g:go_updatetime = 250
au BufNewFile,BufRead *.gohtml setf gohtmltmpl
au BufNewFile,BufRead *.tmpl setf gohtmltmpl
" Rust
let g:rustfmt_autosave = 0
let g:racer_experimental_completer = 1
autocmd BufRead,BufNewFile *.rs set tabstop=4 shiftwidth=4 expandtab
au FileType rust nmap gd <Plug>(rust-def)
au FileType rust nmap K <Plug>(rust-doc)
autocmd BufRead,BufNewFile *.wgsl set tabstop=4 shiftwidth=4 expandtab syntax=rust
" Set keybindings
nnoremap <silent> <Home> ^
vnoremap <silent> <Home> ^
inoremap <silent> <Home> <C-o>^
nnoremap <Tab> <C-w><C-w>
nnoremap <C-\>> <C-w><\>>
nnoremap <C-\<> <C-w><\<>
nnoremap <silent> <Home> ^
vnoremap <silent> <Home> ^
inoremap <silent> <Home> <C-o>^
map <silent> <F5> :nohl<CR>
map <silent> <F5> :nohl<CR>
inoremap <C-Space> <C-x><C-o>
" Disable copying on delete
nnoremap d "_d
vnoremap d "_d
nnoremap D "_D
map q: <nop>
map Q <nop>
" Disable annoying typo bindings
map q: <nop>
map Q <nop>
" LSP
lua << EOF
vim.diagnostic.config({
virtual_text = false,
})
local on_attach = function(client, bufnr)
vim.opt.updatetime = 200
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
-- Show diagnostic popup on cursor hover
local diag_float_grp = vim.api.nvim_create_augroup("DiagnosticFloat", { clear = true })
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()
vim.diagnostic.open_float(nil, { focusable = false })
end,
group = diag_float_grp,
})
local format_sync_grp = vim.api.nvim_create_augroup("Format", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.rs",
callback = function()
vim.lsp.buf.format({ timeout_ms = 200 })
end,
group = format_sync_grp,
})
end
require'lspconfig'.rust_analyzer.setup{
on_attach=on_attach,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
},
},
}
require'lspconfig'.gopls.setup{
on_attach=on_attach,
}
EOF