dotfiles/.config/nvim/init.vim
Quantum 4b8c565254 nvim + some stuff I forgot to commit
New nvim config (dumpster fire)
`less` color fixes
prompt hostname fix
add blugon
2024-06-08 10:06:39 -04:00

204 lines
5.9 KiB
VimL

set nocompatible
filetype off
colorscheme torte
let mapleader = " "
" ----[Plugins]----
call plug#begin()
" Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
" Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
" Plug 'ms-jpq/coq.thirdparty', {'branch': '3p'}
" Plug 'neovim/nvim-lspconfig'
" Plug 'williamboman/nvim-lsp-installer'
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tikhomirov/vim-glsl'
Plug 'powerman/vim-plugin-AnsiEsc'
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'L3MON4D3/LuaSnip'
Plug 'VonHeikemen/lsp-zero.nvim', {'branch': 'v3.x'}
Plug '~/.config/nvim/plugins/qt-uic'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.6' }
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-context'
Plug 'mbbill/undotree'
Plug 'tpope/vim-fugitive'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && npx --yes yarn install' }
call plug#end()
" ----[COQ]----
" let g:coq_settings = {'auto_start': 'shut-up', 'display.pum.fast_close': v:false}
" ----[NVim LSPConfig]----
lua << EOF
local lsp = require 'lspconfig'
local qt_uic = require 'qt_uic'
-- local coq = require 'coq'
-- lsp.cmake.setup{}
-- lsp.pyright.setup{}
-- lsp.clangd.setup{coq.lsp_ensure_capabilities{}}
-- lsp.cmake.setup{coq.lsp_ensure_capabilities{}}
-- lsp.pyright.setup{coq.lsp_ensure_capabilities{}}
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp_zero.default_keymaps({buffer = bufnr})
end)
vim.diagnostic.config({
virtual_text = false
})
-- to learn how to use mason.nvim with lsp-zero
-- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md
require('mason').setup({})
require('mason-lspconfig').setup({
handlers = {
function(server_name)
require('lspconfig')[server_name].setup({})
end,
}
})
lsp.clangd.setup{}
lsp.cmake.setup{}
lsp.pyright.setup{}
-- lsp.clangd.setup{coq.lsp_ensure_capabilities{}}
-- lsp.cmake.setup{coq.lsp_ensure_capabilities{}}
-- lsp.pyright.setup{coq.lsp_ensure_capabilities{}}
lsp.pyright.setup{qt_uic.extend_lsp_completion{}}
require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all"
ensure_installed = {
"vimdoc", "c", "cpp", "bash", "python",
},
-- 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 = true,
highlight = {
-- `false` will disable the whole extension
enable = true,
-- 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,
},
})
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation)
--vim.keymap.set('n', '<leader>e', vim.lsp.diagnostic.show_line_diagnostics)
vim.keymap.set('n', 'grn', vim.lsp.buf.rename)
vim.keymap.set('n', 'gra', vim.lsp.buf.code_action)
vim.keymap.set('n', 'grr', vim.lsp.buf.references)
vim.keymap.set('i', '^S', vim.lsp.buf.signature_help)
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)
vim.keymap.set('n', '<leader>gs', vim.cmd.Git)
vim.opt.scrolloff = 8
vim.opt.signcolumn = 'yes'
vim.opt.isfname:append('@-@')
EOF
" ----[Look and Feel]----
" Syntax hilighting and line numbers
syntax on
set encoding=utf-8
set number relativenumber
set wildmode=longest,list,full
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
set title
" Indents
filetype plugin indent on
" Tabbing
set tabstop=4
set shiftwidth=4
set softtabstop=4 expandtab
" Splits below and right
set splitbelow splitright
" Block cursor
set guicursor=i:block
" ----[File Specific Stuff]----
" yml
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType yml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType meson setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType xacro setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType xml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType urdf setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType idl setlocal ts=2 sts=2 sw=2 expandtab
autocmd! BufNewFile,BufRead *.vs,*.fs,*.glvs,*.glfs,*.glsl set ft=glsl
" ----[NERDTree]----
nnoremap <tab> :NERDTreeToggle<cr>
" ----[Macros]----
" Find and replace macro
nnoremap S :%s//g<Left><Left>
nnoremap <C-u> <C-u>zz
nnoremap <C-d> <C-d>zz
" Copy paste
vnoremap <C-c> "+y
map <C-p> "+P
" xnoremap <leader>p "_dP
" sudo write, TODO: make this not fuck things up
" command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
" ----[Pre / Post Write]----
" Get rid of extra whitespace
autocmd BufWritePre * %s/\s\+$//e
" Run xrdb when Xresources or Xdefaults are changed
autocmd BufWritePost *Xresources,*Xdefaults !xrdb %
" Reload sxhkd when config is edited
autocmd BufWritePost sxhkdrc :silent !pkill sxhkd; sxhkd &
autocmd BufNewFile,BufRead *.compute set syntax=hlsl