336 lines
10 KiB
VimL
336 lines
10 KiB
VimL
set nocompatible " stops wack stuff
|
|
set wildmenu " better command line completion
|
|
set showmode " show editing mode
|
|
set showcmd " show partial commands
|
|
set encoding=UTF-8
|
|
set title
|
|
|
|
" spellcheck
|
|
set spelllang=en,fr,de,cjk
|
|
set spellsuggest=best,9
|
|
nnoremap <silent> <F11> :set spell!<cr>
|
|
inoremap <silent> <F11> <C-O>:set spell!<cr>
|
|
|
|
" use case-insensitive search except when using capitals
|
|
set ignorecase
|
|
set smartcase
|
|
|
|
set backspace=indent,eol,start " Allow backspacing over autoindent, line breaks and start of insert action
|
|
set nostartofline " stop certain things from going to first character in line
|
|
set ruler " display cursor position
|
|
set confirm " ask to save stuff before failed command
|
|
set visualbell " visual indicator instead of beep
|
|
set t_vb= " reset terminal code for visual bell
|
|
|
|
set cmdheight=2 " set command window height to 2 lines
|
|
set number " display line numbers
|
|
set notimeout ttimeout ttimeoutlen=200 " timeout on keycodes but not mappings
|
|
|
|
" Indentation Stuff
|
|
set shiftwidth=4
|
|
set tabstop=4
|
|
set autoindent " keep indent of file or smth
|
|
|
|
" Use <Tab> and <S-Tab> to navigate through pop-up menu
|
|
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
|
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
|
|
|
nnoremap f <cmd>NERDTreeToggle<cr>
|
|
nnoremap t <cmd>ToggleTerm<cr>
|
|
|
|
set lazyredraw
|
|
|
|
" auto-indenting
|
|
if has('filetype')
|
|
filetype indent plugin on
|
|
endif
|
|
|
|
" syntax highlighting
|
|
if has('syntax')
|
|
syntax on
|
|
endif
|
|
|
|
" latex config
|
|
let g:tex_flavor = 'latex'
|
|
let g:tex_conceal = ''
|
|
"let g:vimtex_fold_manual = 1
|
|
"let g:vimtex_latexmk_continuous = 1
|
|
"let g:vimtex_compiler_progname = 'nvr'
|
|
|
|
" Plugins will be downloaded under the specified directory.
|
|
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
|
|
|
|
" Declare the list of plugins.
|
|
|
|
" Theme
|
|
Plug 'catppuccin/nvim', {'as': 'catppuccin'}
|
|
|
|
" Statusline plugin
|
|
Plug 'feline-nvim/feline.nvim', { 'branch': 'develop' }
|
|
|
|
" Misc
|
|
Plug 'glepnir/dashboard-nvim' " startup dashboard
|
|
Plug 'kyazdani42/nvim-web-devicons' " icons!
|
|
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " better syntax highlighting
|
|
Plug 'lewis6991/spellsitter.nvim' " treesitter for spelling
|
|
|
|
Plug 'akinsho/toggleterm.nvim' " better terminal support
|
|
|
|
Plug 'alaviss/nim.nvim' " nim language support
|
|
Plug 'HiPhish/guile.vim' " guile language support
|
|
Plug 'karolbelina/uxntal.vim' " uxn language support
|
|
|
|
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " searching
|
|
Plug 'junegunn/fzf.vim'
|
|
|
|
Plug 'tpope/vim-commentary' " commenting tool
|
|
Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' } " show colours
|
|
"Plug 'folke/trouble.nvim'
|
|
|
|
" git signs
|
|
Plug 'nvim-lua/plenary.nvim'
|
|
Plug 'lewis6991/gitsigns.nvim'
|
|
|
|
" LaTeX
|
|
"Plug 'lervag/vimtex'
|
|
Plug 'Konfekt/FastFold' " speeds or folding or smth
|
|
Plug 'matze/vim-tex-fold'
|
|
|
|
" rust-lsp configuration
|
|
Plug 'neovim/nvim-lspconfig'
|
|
Plug 'hrsh7th/nvim-cmp' " completion framework
|
|
Plug 'hrsh7th/cmp-nvim-lsp' " LSP completion source for nvim-cmp
|
|
Plug 'hrsh7th/cmp-vsnip' " snippet completion source for nvim-cmp
|
|
Plug 'hrsh7th/cmp-path' " other usefull completion sources
|
|
Plug 'hrsh7th/cmp-buffer'
|
|
Plug 'simrat39/rust-tools.nvim'
|
|
Plug 'hrsh7th/vim-vsnip' " snippet engine
|
|
" Plug 'nvim-lua/lsp_extensions.nvim'
|
|
|
|
" File tree
|
|
Plug 'preservim/nerdtree'
|
|
Plug 'Xuyuanp/nerdtree-git-plugin' " git status icons
|
|
"Plug 'ryanoasis/vim-devicons'
|
|
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " syntax highlighting?
|
|
Plug 'ryanoasis/vim-devicons' " icons
|
|
|
|
" Optional dependencies
|
|
Plug 'nvim-lua/popup.nvim'
|
|
" Plug 'nvim-telescope/telescope.nvim'
|
|
|
|
call plug#end()
|
|
|
|
" Set colour scheme
|
|
autocmd vimenter * ++nested colorscheme catppuccin
|
|
colorscheme catppuccin
|
|
|
|
let g:Hexokinase_highlighters = ['sign_column']
|
|
|
|
" Setup plugins
|
|
lua require('feline').setup({components = require('catppuccin.core.integrations.feline'),})
|
|
lua require('gitsigns').setup()
|
|
lua require('spellsitter').setup()
|
|
lua require("toggleterm").setup{}
|
|
|
|
" Default value is clap
|
|
let g:dashboard_default_executive ='fzf'
|
|
let g:dashboard_preview_command = 'cat'
|
|
let g:dashboard_preview_pipeline = 'lolcat'
|
|
let g:dashboard_preview_file = '~/.config/nvim/neovim.cat'
|
|
let g:dashboard_preview_file_height = 16
|
|
let g:dashboard_preview_file_width = 33
|
|
|
|
" trouble config
|
|
" seems to be broken rn?
|
|
" lua require("trouble").setup()
|
|
|
|
lua <<EOF
|
|
require'nvim-web-devicons'.setup {
|
|
-- your personnal icons can go here (to override)
|
|
-- you can specify color or cterm_color instead of specifying both of them
|
|
-- DevIcon will be appended to `name`
|
|
override = {
|
|
zsh = {
|
|
icon = "",
|
|
color = "#428850",
|
|
cterm_color = "65",
|
|
name = "Zsh"
|
|
}
|
|
};
|
|
-- globally enable default icons (default to false)
|
|
-- will get overriden by `get_icons` option
|
|
default = true;
|
|
}
|
|
EOF
|
|
|
|
" Setup treesitter
|
|
lua <<EOF
|
|
require'nvim-treesitter.configs'.setup {
|
|
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
|
|
ensure_installed = "maintained",
|
|
|
|
-- Install languages synchronously (only applied to `ensure_installed`)
|
|
sync_install = true,
|
|
|
|
-- List of parsers to ignore installing
|
|
ignore_install = { "javascript", "typescript" },
|
|
|
|
highlight = {
|
|
-- `false` will disable the whole extension
|
|
enable = true,
|
|
|
|
-- list of language that will be disabled
|
|
|
|
-- 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
|
|
|
|
" Rust LSP setup based on https://sharksforarms.dev/posts/neovim-rust/
|
|
|
|
" Set completeopt to have a better completion experience
|
|
" :help completeopt
|
|
" menuone: popup even when there's only one match
|
|
" noinsert: Do not insert text until a selection is made
|
|
" noselect: Do not select, force user to select one from the menu
|
|
set completeopt=menuone,noinsert,noselect
|
|
|
|
" Avoid showing extra messages when using completion
|
|
set shortmess+=c
|
|
|
|
|
|
" Configure LSP through rust-tools.nvim plugin.
|
|
" rust-tools will configure and enable certain LSP features for us.
|
|
" See https://github.com/simrat39/rust-tools.nvim#configuration
|
|
lua <<EOF
|
|
local nvim_lsp = require'lspconfig'
|
|
|
|
local opts = {
|
|
tools = { -- rust-tools options
|
|
autoSetHints = true,
|
|
hover_with_actions = true,
|
|
inlay_hints = {
|
|
show_parameter_hints = false,
|
|
parameter_hints_prefix = "",
|
|
other_hints_prefix = "",
|
|
},
|
|
},
|
|
|
|
-- all the opts to send to nvim-lspconfig
|
|
-- these override the defaults set by rust-tools.nvim
|
|
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
|
|
server = {
|
|
-- on_attach is a callback called when the language server attachs to the buffer
|
|
-- on_attach = on_attach,
|
|
settings = {
|
|
-- to enable rust-analyzer settings visit:
|
|
-- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc
|
|
["rust-analyzer"] = {
|
|
-- enable clippy on save
|
|
checkOnSave = {
|
|
command = "clippy"
|
|
},
|
|
}
|
|
}
|
|
},
|
|
}
|
|
|
|
require('rust-tools').setup(opts)
|
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
|
-- map buffer local keybindings when the language server attaches
|
|
local servers = { 'pylsp', 'asm_lsp', 'gdscript' }
|
|
for _, lsp in pairs(servers) do
|
|
require('lspconfig')[lsp].setup {
|
|
on_attach = on_attach,
|
|
flags = {
|
|
-- This will be the default in neovim 0.7+
|
|
debounce_text_changes = 150,
|
|
}
|
|
}
|
|
end
|
|
EOF
|
|
|
|
" Setup Completion
|
|
" See https://github.com/hrsh7th/nvim-cmp#basic-configuration
|
|
lua <<EOF
|
|
local cmp = require'cmp'
|
|
cmp.setup({
|
|
-- Enable LSP snippets
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
-- Add tab support
|
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.close(),
|
|
['<CR>'] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
select = true,
|
|
})
|
|
},
|
|
|
|
-- Installed sources
|
|
sources = {
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'vsnip' },
|
|
{ name = 'path' },
|
|
{ name = 'buffer' },
|
|
},
|
|
})
|
|
EOF
|
|
|
|
" Code navigation shortcuts
|
|
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
|
|
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
|
|
nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
|
|
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
|
|
nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
|
|
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
|
|
nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
|
|
nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
|
|
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
|
|
nnoremap <silent> ga <cmd>lua vim.lsp.buf.code_action()<CR>
|
|
|
|
" Set updatetime for CursorHold
|
|
" 300ms of no cursor movement to trigger CursorHold
|
|
set updatetime=300
|
|
" Show diagnostic popup on cursor hold
|
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
|
|
|
" Goto previous/next diagnostic warning/error
|
|
nnoremap <silent> g[ <cmd>lua vim.diagnostic.goto_prev()<CR>
|
|
nnoremap <silent> g] <cmd>lua vim.diagnostic.goto_next()<CR>
|
|
" have a fixed column for the diagnostics to appear in
|
|
" this removes the jitter when warnings/errors flow in
|
|
set signcolumn=yes
|
|
" Auto-format *.rs (rust) files prior to saving them
|
|
autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000)
|
|
|
|
" Terminal stuff
|
|
lua <<EOF
|
|
function _G.set_terminal_keymaps()
|
|
local opts = {noremap = true}
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
|
|
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
|
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
|
end
|
|
|
|
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
|
EOF
|