Various things, but mostly rust and treesitter related
This commit is contained in:
parent
5d3264a3ce
commit
ded7f54b60
163
init.vim
163
init.vim
@ -75,6 +75,7 @@
|
|||||||
Plug 'morhetz/gruvbox' " alternate theme
|
Plug 'morhetz/gruvbox' " alternate theme
|
||||||
Plug 'sonph/onehalf', {'rtp': 'vim/'} " altenate theme
|
Plug 'sonph/onehalf', {'rtp': 'vim/'} " altenate theme
|
||||||
Plug 'romainl/vim-dichromatic' " colorblind theme
|
Plug 'romainl/vim-dichromatic' " colorblind theme
|
||||||
|
Plug 'j-hui/fidget.nvim' " UI for notifications and progress info
|
||||||
|
|
||||||
" Linting
|
" Linting
|
||||||
Plug 'neomake/neomake'
|
Plug 'neomake/neomake'
|
||||||
@ -83,11 +84,15 @@
|
|||||||
\ 'do': 'make fsautocomplete',
|
\ 'do': 'make fsautocomplete',
|
||||||
\}
|
\}
|
||||||
Plug 'JuliaEditorSupport/julia-vim'
|
Plug 'JuliaEditorSupport/julia-vim'
|
||||||
Plug 'rust-lang/rust.vim'
|
Plug 'alx741/vim-rustfmt'
|
||||||
Plug 'tikhomirov/vim-glsl'
|
Plug 'tikhomirov/vim-glsl'
|
||||||
|
|
||||||
" Language server
|
" Language server
|
||||||
Plug 'neovim/nvim-lspconfig'
|
Plug 'neovim/nvim-lspconfig'
|
||||||
|
Plug 'simrat39/rust-tools.nvim'
|
||||||
|
|
||||||
|
" Support for DAP (Debug Adapter Protocol)
|
||||||
|
Plug 'mfussenegger/nvim-dap'
|
||||||
|
|
||||||
" Fuzzy finding
|
" Fuzzy finding
|
||||||
" Plug 'jhawthorn/fzy' " Install this systemwide (or configure a manual
|
" Plug 'jhawthorn/fzy' " Install this systemwide (or configure a manual
|
||||||
@ -107,6 +112,7 @@
|
|||||||
|
|
||||||
" commenting code
|
" commenting code
|
||||||
Plug 'tpope/vim-commentary'
|
Plug 'tpope/vim-commentary'
|
||||||
|
Plug 'JoosepAlviste/nvim-ts-context-commentstring' " Automatically set commentstring based on treesitter
|
||||||
|
|
||||||
" shell commands without having to leave vim (eg. rename)
|
" shell commands without having to leave vim (eg. rename)
|
||||||
Plug 'tpope/vim-eunuch'
|
Plug 'tpope/vim-eunuch'
|
||||||
@ -195,7 +201,7 @@
|
|||||||
Plug 'rlue/vim-barbaric'
|
Plug 'rlue/vim-barbaric'
|
||||||
|
|
||||||
" Arduino integration
|
" Arduino integration
|
||||||
if system('command -v arduino-cli') != ""
|
if executable("arduino-cli")
|
||||||
Plug 'stevearc/vim-arduino'
|
Plug 'stevearc/vim-arduino'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -203,6 +209,9 @@
|
|||||||
Plug 'janko-m/vim-test'
|
Plug 'janko-m/vim-test'
|
||||||
|
|
||||||
" Syntax highlighting {{{
|
" Syntax highlighting {{{
|
||||||
|
" Better syntax highlighting using Tree-sitter
|
||||||
|
" This is the preferred method
|
||||||
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||||
|
|
||||||
" Bedre perl-highlighting
|
" Bedre perl-highlighting
|
||||||
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp highlight-all-pragmas moose test-more try-tiny method-signatures' }
|
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp highlight-all-pragmas moose test-more try-tiny method-signatures' }
|
||||||
@ -254,7 +263,7 @@ tnoremap <Esc> <C-\><C-n>
|
|||||||
" UI config {{{
|
" UI config {{{
|
||||||
" Enable syntax highlighting
|
" Enable syntax highlighting
|
||||||
syntax on
|
syntax on
|
||||||
syntax enable
|
" syntax enable
|
||||||
set conceallevel=0
|
set conceallevel=0
|
||||||
|
|
||||||
" Highlight unwanted whitespaces
|
" Highlight unwanted whitespaces
|
||||||
@ -286,27 +295,9 @@ tnoremap <Esc> <C-\><C-n>
|
|||||||
" autocmd filetype markdown syntax match markdownIgnore "\\begin{\(\$\|gather\*\?\|align\*\?\)}.*_.*\\end{\1}" containedin=markdown
|
" autocmd filetype markdown syntax match markdownIgnore "\\begin{\(\$\|gather\*\?\|align\*\?\)}.*_.*\\end{\1}" containedin=markdown
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" " Colorscheme
|
|
||||||
" let base16colorspace=256
|
|
||||||
" " colorscheme base16-gruvbox-dark-hard
|
|
||||||
" colorscheme base16-solarized-dark
|
|
||||||
" let g:solarized_termcolors=256
|
|
||||||
" " colorscheme dracula
|
|
||||||
" " set background=dark
|
|
||||||
" " disables opaque background
|
|
||||||
" " NOTE: When a transparent background is needed, ":color default" is
|
|
||||||
" " easier
|
|
||||||
" " hi Normal ctermbg=NONE guibg=NONE
|
|
||||||
" " hi NonText ctermbg=NONE guibg=NONE
|
|
||||||
|
|
||||||
" Gruvbox {{{
|
|
||||||
" let g:gruvbox_italic=1
|
|
||||||
" let g:gruvbox_contrast_dark='hard'
|
|
||||||
" colorscheme gruvbox
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" dichromatic
|
" dichromatic
|
||||||
colorscheme dichromatic
|
colorscheme dichromatic
|
||||||
|
|
||||||
" Recolor selected line in QuickFix window
|
" Recolor selected line in QuickFix window
|
||||||
hi QuickFixLine ctermbg=15 ctermfg=240 cterm=NONE guibg=#585858 guifg=#FFFFFF gui=NONE
|
hi QuickFixLine ctermbg=15 ctermfg=240 cterm=NONE guibg=#585858 guifg=#FFFFFF gui=NONE
|
||||||
hi Pmenu ctermbg=17 guibg=#00005F ctermfg=252 guifg=#DADADA
|
hi Pmenu ctermbg=17 guibg=#00005F ctermfg=252 guifg=#DADADA
|
||||||
@ -403,6 +394,10 @@ set smartcase
|
|||||||
|
|
||||||
" < and > will hit indentation levels instead of always -4/+4
|
" < and > will hit indentation levels instead of always -4/+4
|
||||||
set shiftround
|
set shiftround
|
||||||
|
|
||||||
|
" Don't move comments/preprocessor directives starting with # to the
|
||||||
|
" beginning of the line
|
||||||
|
set cinkeys-=0#
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" Highlight tabs and trailing whitespace {{{
|
" Highlight tabs and trailing whitespace {{{
|
||||||
@ -595,8 +590,10 @@ endif
|
|||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
" Configure for Rust
|
" Configure for Rust
|
||||||
|
" Replace with rust-analyzer via the LSP
|
||||||
" let g:neomake_rust_enabled_makers = ['rustc', 'cargo']
|
" let g:neomake_rust_enabled_makers = ['rustc', 'cargo']
|
||||||
let g:neomake_rust_enabled_makers = ['cargo']
|
" let g:neomake_rust_enabled_makers = ['cargo']
|
||||||
|
let g:neomake_rust_enabled_makers = [] " Disable Neomake
|
||||||
|
|
||||||
" Configure for Haskell
|
" Configure for Haskell
|
||||||
let g:neomake_haskell_enabled_makers = ['hlint']
|
let g:neomake_haskell_enabled_makers = ['hlint']
|
||||||
@ -799,7 +796,7 @@ EOF
|
|||||||
highlight SignColumn ctermbg=none
|
highlight SignColumn ctermbg=none
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Configure Vim-Commentary
|
" Configure Vim-Commentary {{{
|
||||||
augroup CustomCommentDefinitions
|
augroup CustomCommentDefinitions
|
||||||
function! SetCommentString()
|
function! SetCommentString()
|
||||||
let syntaxGroups = map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')
|
let syntaxGroups = map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')
|
||||||
@ -836,6 +833,30 @@ augroup CustomCommentDefinitions
|
|||||||
" autocmd CursorMoved * :call SetCommentString()
|
" autocmd CursorMoved * :call SetCommentString()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
" Preemptive configuration for when languages are parsed using treesitter in
|
||||||
|
" the future
|
||||||
|
lua <<END
|
||||||
|
require 'ts_context_commentstring'.setup {
|
||||||
|
enable_autocmd = false,
|
||||||
|
languages = {
|
||||||
|
c = '// %s',
|
||||||
|
cpp = '// %s',
|
||||||
|
cuda = '// %s',
|
||||||
|
arduino = '// %s',
|
||||||
|
openscad = '// %s',
|
||||||
|
dot = '// %s',
|
||||||
|
matlab = '% %s',
|
||||||
|
julia = '# %s',
|
||||||
|
nix = '# %s',
|
||||||
|
markdown = '<!--- %s -->',
|
||||||
|
-- html.epl = '%# %s', -- the . in the file type is problematic...
|
||||||
|
-- vue is supported by default
|
||||||
|
-- html is supported by default... how does it handle glsl in html?
|
||||||
|
},
|
||||||
|
}
|
||||||
|
END
|
||||||
|
" }}}
|
||||||
|
|
||||||
" NCM2
|
" NCM2
|
||||||
augroup NCM2
|
augroup NCM2
|
||||||
autocmd!
|
autocmd!
|
||||||
@ -849,9 +870,11 @@ augroup NCM2
|
|||||||
" Suppress the annoying 'match x of y', 'The only match' and 'Pattern not
|
" Suppress the annoying 'match x of y', 'The only match' and 'Pattern not
|
||||||
" found' messages
|
" found' messages
|
||||||
set shortmess+=c
|
set shortmess+=c
|
||||||
" Use <TAB> to select the popup menu:
|
" Use <TAB> instead of arrow keys to select the popup menu:
|
||||||
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
||||||
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
||||||
|
inoremap <expr> <up> pumvisible() ? '<c-e><up>' : '<up>'
|
||||||
|
inoremap <expr> <down> pumvisible() ? '<c-e><down>' : '<down>'
|
||||||
|
|
||||||
" Configure float-preview
|
" Configure float-preview
|
||||||
let g:float_preview#docked = 1
|
let g:float_preview#docked = 1
|
||||||
@ -870,6 +893,17 @@ augroup NCM2
|
|||||||
" C/C++
|
" C/C++
|
||||||
let g:ncm2_pyclang#library_path = '/usr/lib/libclang.so'
|
let g:ncm2_pyclang#library_path = '/usr/lib/libclang.so'
|
||||||
autocmd FileType c,cpp nnoremap <buffer> gd :<c-u>call ncm2_pyclang#goto_declaration()<cr>
|
autocmd FileType c,cpp nnoremap <buffer> gd :<c-u>call ncm2_pyclang#goto_declaration()<cr>
|
||||||
|
|
||||||
|
" Rust
|
||||||
|
" Documented in https://github.com/ncm2/ncm2/pull/178
|
||||||
|
au User Ncm2Plugin call ncm2#register_source({
|
||||||
|
\ 'name' : 'Rust',
|
||||||
|
\ 'priority': 9,
|
||||||
|
\ 'scope': ['rust'],
|
||||||
|
\ 'mark': 'RLS',
|
||||||
|
\ 'complete_pattern': ['\.', ':'],
|
||||||
|
\ 'on_complete': 'ncm2#on_complete#lsp',
|
||||||
|
\ })
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" VimTex {{
|
" VimTex {{
|
||||||
@ -1305,7 +1339,7 @@ lua <<EOF
|
|||||||
-- Go to definition
|
-- Go to definition
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||||
-- Show perldoc for function under cursor
|
-- Show perldoc for function under cursor
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
vim.keymap.set('n', 'K', vim.sp.buf.hover, bufopts)
|
||||||
-- Show list of function in current module (kræver FZF)
|
-- Show list of function in current module (kræver FZF)
|
||||||
vim.keymap.set('n', 'L', jix_lsp.document_functions, bufopts)
|
vim.keymap.set('n', 'L', jix_lsp.document_functions, bufopts)
|
||||||
-- Show signature for function under cursor (virker i skrivende stund ikke med subroutine signatures)
|
-- Show signature for function under cursor (virker i skrivende stund ikke med subroutine signatures)
|
||||||
@ -1319,7 +1353,7 @@ lua <<EOF
|
|||||||
vim.api.nvim_command('silent NeomakeDisableBuffer')
|
vim.api.nvim_command('silent NeomakeDisableBuffer')
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = {
|
local perlpls_config = {
|
||||||
cmd = { 'jix-shell', 'pls' },
|
cmd = { 'jix-shell', 'pls' },
|
||||||
filetypes = { 'perl' },
|
filetypes = { 'perl' },
|
||||||
root_dir = util.find_git_ancestor,
|
root_dir = util.find_git_ancestor,
|
||||||
@ -1341,6 +1375,79 @@ lua <<EOF
|
|||||||
handlers = jix_lsp.handlers,
|
handlers = jix_lsp.handlers,
|
||||||
}
|
}
|
||||||
|
|
||||||
require 'lspconfig'.perlpls.setup(config)
|
require 'lspconfig'.perlpls.setup(perlpls_config)
|
||||||
EOF
|
EOF
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Rust LSP {{{
|
||||||
|
" Requires rust-analyzer to be installed on the system
|
||||||
|
let g:rustfmt_on_save = 1 " vim-rustfmt
|
||||||
|
lua <<EOF
|
||||||
|
local rt = require 'rust-tools'
|
||||||
|
rt.setup({
|
||||||
|
server = {
|
||||||
|
on_attach = function(_, bufnr)
|
||||||
|
|
||||||
|
-- vim.keymap.set("n", "<Leader>ll", ':w <CR> :!cargo run <CR>', { buffer = bufnr })
|
||||||
|
vim.keymap.set("n", "<Leader>ll", ":w <CR> :!cargo run 3>&2 2>&1 1>&3 | grep -o 'could not find `Cargo.toml`' > /dev/null && (rustc %:p && %:p:r)<CR>", { buffer = bufnr })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
tools = {
|
||||||
|
inlay_hints = {
|
||||||
|
auto = true, -- enable inlay_hints
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
EOF
|
||||||
|
" }}}
|
||||||
|
|
||||||
|
" Setup fidget
|
||||||
|
lua <<EOF
|
||||||
|
require("fidget").setup {
|
||||||
|
-- options
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
lua <<EOF
|
||||||
|
require 'nvim-treesitter.configs'.setup({
|
||||||
|
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||||
|
ensure_installed = {
|
||||||
|
"c", "lua", "vim", "vimdoc", "query", -- required for Neovim itself
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||||
|
sync_install = false,
|
||||||
|
|
||||||
|
-- Automatically install missing parsers when entering buffer
|
||||||
|
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||||
|
auto_install = false,
|
||||||
|
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
|
||||||
|
disable = function(lang, buf)
|
||||||
|
-- Disable specific languages
|
||||||
|
local disabled = { }
|
||||||
|
for i=1,#disabled do
|
||||||
|
if disabled[i] == lang then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Disable for large files
|
||||||
|
local max_filesize = 100 * 1024 -- 100 KB
|
||||||
|
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||||
|
if ok and stats and stats.size > max_filesize then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||||
|
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||||
|
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||||
|
-- Instead of true it can also be a list of languages
|
||||||
|
additional_vim_regex_highlighting = false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
EOF
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user