diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..ece59b0 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,87 @@ +vim.o.go = 'a' +vim.o.showmode = false + +-- disable netrw +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- enable mouse for all modes +vim.o.mouse = 'a' +vim.o.clipboard = 'unnamedplus' + +-- basic color settings +vim.o.background = 'dark' + +-- setting Tab-length +vim.o.expandtab = true +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 + +-- splits open at the bottom and right +vim.o.splitbelow = true +vim.o.splitright = true + +-- disable case sensitive matching +vim.o.ignorecase = true + +-- enable nocompatible mode +vim.o.nocompatible = true + +-- enable syntax highlighting +vim.o.syntax = true + +-- enable true colors +vim.o.termguicolors = true + +-- set utf-8 encoding +vim.o.encoding = "utf-8" + +-- show relative numbers on left side +vim.o.number = true +vim.o.relativenumber = true + +-- speedup vim with long lines +vim.o.ttyfast = true +vim.o.lazyredraw = true + +-- textEdit might fail without hidden +vim.o.hidden = true + +-- disable backupfiles +vim.o.nobackup = true +vim.o.nowritebackup = true + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- always show the signcolumn +vim.o.signcolumn = "yes" + +-- enable persistent undo +vim.o.undofile = true +vim.o.undodir = vim.env.XDG_CACHE_HOME .. "/vim/undo" + +-- python programs to use +vim.g.python_host_prog = '/usr/bin/python2' +vim.g.python3_host_prog = '/usr/bin/python3' + +-- display certain invisible chars +vim.opt.list = true +vim.opt.listchars:append "space:·" +vim.opt.listchars:append "eol:" + +-- folding +vim.o.foldcolumn = '0' +vim.o.foldlevel = 99 +vim.o.foldlevelstart = 99 +vim.o.foldenable = true + + +-- set filetypes correctly by extension +require('autocmd') + +-- load plugins (autoload all files in plugin folder) +require('loadplugins') + +-- load general mapped keys +require('keymap') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim deleted file mode 100644 index 180a357..0000000 --- a/.config/nvim/init.vim +++ /dev/null @@ -1,162 +0,0 @@ -let mapleader = "," - -" begin plugin section -if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) - echo "Downloading junegunn/vim-plug to manage plugins..." - silent !mkdir -p ~/.config/nvim/autoload/ - silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim -endif - -call plug#begin('~/.config/nvim/plugged') -Plug 'qpkorr/vim-renamer' -Plug 'tomasiser/vim-code-dark' -call plug#end() -" end plugin section - -set go=a - -" enable mouse for all modes -set mouse=a -set clipboard+=unnamedplus - -" enable command completion -set wildmode=longest,list,full - -" setting Tab-length -set expandtab -set softtabstop=4 -set shiftwidth=4 - -" splits open at the bottom and right, which is non-retarded, unlike vim defaults. -set splitbelow splitright - -" disable case sensitive matching -set ignorecase - -" enable nocompatible mode -set nocompatible - -" enable Plugins -filetype plugin on - -" enable syntax highlighting -syntax on - -" enable true colors -set termguicolors - -" set utf-8 encoding -set encoding=utf-8 - -" show relative numbers on left side -set number relativenumber - -" speedup vim with long lines -set ttyfast -set lazyredraw - -" textEdit might fail without hidden -set hidden - -" disable Backupfiles for Lsp -set nobackup -set nowritebackup - -" dont pass messages to ins-completion-menu -set shortmess+=c - -" always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -if has("patch-8.1.1564") - " Recently vim can merge signcolumn and number column into one - set signcolumn=number -else - set signcolumn=yes -endif - -" enable persistent undo -if has('persistent_undo') - set undofile - set undodir="$XDG_CACHE_HOME/vim/undo" -endif - -" unmap unwanted commands -nnoremap -nnoremap -nnoremap -nnoremap -nnoremap -nnoremap -nnoremap -nnoremap -nnoremap -nnoremap - -inoremap -inoremap -inoremap -inoremap -inoremap -inoremap -inoremap -inoremap -inoremap -inoremap -inoremap -inoremap - -" mapping Dictionaries -nnoremap :setlocal spell! spelllang=de_de -nnoremap :setlocal spell! spelllang=en_us - -" compiler for languages -nnoremap c :w! \| !compiler % - -" open corresponding file (pdf/html/...) -nnoremap p :!opout % - -" shortcut for split navigation -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -" save file as sudo on files that require root permission -cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! - -" alias for replacing -nnoremap ss :%s//gI - -" delete trailing whitespaces on save -fun! TrimWhitespace() - let l:save = winsaveview() - keeppatterns %s/\s\+$//e - call winrestview(l:save) -endfun -autocmd BufWritePre * :call TrimWhitespace() - -" read files correctly -autocmd BufRead,BufNewFile *.tex set filetype=tex -autocmd BufRead,BufNewFile *.h set filetype=c - -" formatting -autocmd FileType c setlocal formatprg=astyle\ --mode=c -autocmd FileType java setlocal formatprg=astyle\ --indent=spaces=2\ --style=google -autocmd FileType java setlocal shiftwidth=2 softtabstop=2 -autocmd FileType markdown noremap :silent %!prettier --stdin-filepath % -autocmd FileType python setlocal formatprg=autopep8\ - -autocmd FileType tex,latex setlocal formatprg=latexindent\ - -autocmd FileType c,java,python,tex,latex noremap gggqG - -" cleanup certain files after leaving the editor -autocmd VimLeave *.tex !texclear % -autocmd VimLeave *.c !cclear - -" highlighting break line -autocmd BufEnter,FileType c set colorcolumn=80 -autocmd BufEnter,FileType java set colorcolumn=100 -autocmd BufEnter,FileType markdown set colorcolumn=80 - -" colorscheme -colorscheme codedark -highlight colorcolumn guibg=#772222 diff --git a/.config/nvim/lua/autocmd.lua b/.config/nvim/lua/autocmd.lua new file mode 100644 index 0000000..f1174ea --- /dev/null +++ b/.config/nvim/lua/autocmd.lua @@ -0,0 +1,117 @@ +-- autocmd + +-- read files correctly +vim.filetype.add({ + extension = { + c = 'c', + h = 'c', + html = 'html', + java = 'java', + js = 'javascript', + lua = 'lua', + md = 'markdown', + nim = 'nim', + py = 'python', + tex = 'tex', + } +}) + +-- settings for filetype: c + +vim.api.nvim_create_autocmd({ 'VimLeave' }, + { + pattern = { 'c' }, + command = '!cclear' + }) + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'c' }, + command = 'set colorcolumn=80' + }) + +-- settings for filetype: java + +vim.api.nvim_create_autocmd({ 'FileType' }, + { + pattern = { 'java' }, + command = 'setlocal shiftwidth=2 softtabstop=2', + }) + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'java' }, + command = 'set colorcolumn=100' + }) + +-- settings for filetype: javascript + +vim.api.nvim_create_autocmd({ 'FileType' }, + { + pattern = { 'javascript' }, + command = 'setlocal shiftwidth=2 softtabstop=2', + }) + +-- settings for filetype: lua + +vim.api.nvim_create_autocmd({ 'FileType' }, + { + pattern = { 'lua' }, + command = 'setlocal shiftwidth=2 softtabstop=2', + }) + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'lua' }, + command = 'set colorcolumn=100' + }) + +-- settings for filetype: markdown + +vim.api.nvim_create_autocmd({ 'FileType' }, + { + pattern = { 'markdown' }, + command = 'setlocal shiftwidth=2 softtabstop=2', + }) + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'markdown' }, + command = 'set colorcolumn=100' + }) + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'markdown' }, + command = 'set conceallevel=2' + }) + +-- settings for filetype: nim + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'nim' }, + command = 'set colorcolumn=80' + }) + +-- settings for filetype: python + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'python' }, + command = 'set colorcolumn=80' + }) + +-- settings for filetype: tex + +vim.api.nvim_create_autocmd({ 'VimLeave' }, + { + pattern = { 'tex' }, + command = '!texclear %' + }) + +vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' }, + { + pattern = { 'tex' }, + command = 'set colorcolumn=80' + }) diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua new file mode 100644 index 0000000..1c1d467 --- /dev/null +++ b/.config/nvim/lua/keymap.lua @@ -0,0 +1,84 @@ +-- keymap + +-- set mapleader for hotkeys +vim.g.mapleader = "," + +-- unmap unwanted commands +vim.api.nvim_set_keymap('n', '', '', { noremap = true }) +vim.api.nvim_set_keymap('n', '', '', { noremap = true }) +vim.api.nvim_set_keymap('n', '', '', { noremap = true }) +vim.api.nvim_set_keymap('n', '', '', { noremap = true }) +vim.api.nvim_set_keymap('n', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +vim.api.nvim_set_keymap('i', '', '', { noremap = true }) + +-- shortcut for split navigation +vim.api.nvim_set_keymap('n', '', 'h', { noremap = true }) +vim.api.nvim_set_keymap('n', '', 'j', { noremap = true }) +vim.api.nvim_set_keymap('n', '', 'k', { noremap = true }) +vim.api.nvim_set_keymap('n', '', 'l', { noremap = true }) + +-- mapping Dictionaries +vim.api.nvim_set_keymap('n', '', ':setlocal spell! spelllang=de_de', { noremap = true }) +vim.api.nvim_set_keymap('n', '', ':setlocal spell! spelllang=en_us', { noremap = true }) + +-- compiler for languages +vim.api.nvim_set_keymap('n', 'c', ':w! | !compiler %', { noremap = true }) + +-- save file as sudo on files that require root permission +vim.api.nvim_set_keymap('c', 'w!!', '"silent! write !sudo tee % >/dev/null" edit!', { noremap = true }) + +-- alias for replacing +vim.api.nvim_set_keymap('n', 'ss', ':%s//gI', { noremap = true }) + +-- irc compatibility for interactivity +vim.api.nvim_set_keymap('n', 'is', ':.w >> indd', { noremap = true }) + + +-- open corresponding file (pdf/html/...,md) +vim.api.nvim_set_keymap('n', 'p', ':!opout %', { noremap = true }) + +-- iamcco/markdown-preview.nvim +vim.api.nvim_create_autocmd('FileType', { + pattern = 'markdown', + callback = function() + vim.api.nvim_set_keymap('n', 'p', ':MarkdownPreviewToggle', { noremap = true }) + end, +}) + +-- SmiteshP/nvim-navbuddy +vim.api.nvim_set_keymap('n', '', ':Navbuddy', {}) + +-- nvim-tree/nvim-tree.lua +vim.api.nvim_set_keymap('n', '', ':NvimTreeToggle toggle', {}) + +-- tpope/vim-fugitive +vim.api.nvim_set_keymap('n', 'ga', ':Git add %:p', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gd', ':Git diff', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gc', ':Git commit', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gh', ':diffget //3', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gr', ':Gread', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gu', ':diffget //2', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gs', ':G', { noremap = true }) + +-- hrsh7th/nvim-cmp +vim.api.nvim_set_keymap('n', 'gD', ':lua vim.lsp.buf.declaration()', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gd', ':lua vim.lsp.buf.definition()', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gy', ':lua vim.lsp.buf.type_definition()', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gi', ':lua vim.lsp.buf.implementation()', { noremap = true }) +vim.api.nvim_set_keymap('n', 'gr', ':lua vim.lsp.buf.references()', { noremap = true }) +vim.api.nvim_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()', { noremap = true }) +vim.api.nvim_set_keymap('n', '', ':lua vim.lsp.buf.rename()', { noremap = true }) +vim.api.nvim_set_keymap('n', '', ':lua vim.lsp.buf.format()', { noremap = true }) + +-- nvim-telescope/telescope.nvim +vim.api.nvim_set_keymap('n', '', ':Telescope find_files', { noremap = true }) diff --git a/.config/nvim/lua/loadplugins.lua b/.config/nvim/lua/loadplugins.lua new file mode 100644 index 0000000..e0b9264 --- /dev/null +++ b/.config/nvim/lua/loadplugins.lua @@ -0,0 +1,169 @@ +-- loadplugins + +-- bootstrap lazy +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + + +return require("lazy").setup({ + -- indicate git diff status of line + 'lewis6991/gitsigns.nvim', + + -- show indentation lines (in empty lines too) + 'lukas-reineke/indent-blankline.nvim', + + -- improved java syntax highlighting + { + 'uiiaoo/java-syntax.vim', + ft = { 'java' }, + }, + + -- custom statusline + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons', } + }, + + -- show signature while typing + 'ray-x/lsp_signature.nvim', + + -- preview for markdown filetypes + { + "iamcco/markdown-preview.nvim", + ft = { 'markdown' }, + build = "cd app && yarn install", + }, + + -- latex asynchronous pdf rendering + { + 'donRaphaco/neotex', + ft = { 'tex' }, + }, + + -- nim language support + { + 'zah/nim.vim', + ft = { 'nim' }, + }, + + -- automatic closing of brackets + 'windwp/nvim-autopairs', + + -- autocompletion and its sources + { + 'hrsh7th/nvim-cmp', + dependencies = { 'hrsh7th/cmp-buffer', + -- standalone cmp sources + 'hrsh7th/cmp-path', + 'lukas-reineke/cmp-under-comparator', + -- lsp cmp source + 'neovim/nvim-lspconfig', + 'hrsh7th/cmp-nvim-lsp', + 'onsails/lspkind-nvim', + -- luasnip cmp source + 'l3mon4d3/luasnip', + 'saadparwaiz1/cmp_luasnip', + -- lang server management + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'jose-elias-alvarez/null-ls.nvim', + 'LostNeophyte/null-ls-embedded', + 'jay-babu/mason-null-ls.nvim', + -- dependencies + 'nvim-lua/plenary.nvim', + }, + }, + + -- fix for cursorhold function + 'antoinemadec/fixcursorhold.nvim', + + -- showing color of hex values, etc + 'norcalli/nvim-colorizer.lua', + + -- show tags + { + "SmiteshP/nvim-navbuddy", + dependencies = { + "neovim/nvim-lspconfig", + "SmiteshP/nvim-navic", + "MunifTanjim/nui.nvim", + }, + }, + + -- fileexplorer on the side + { + "nvim-tree/nvim-tree.lua", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + }, + + -- better language highlighting by improved parsing + 'nvim-treesitter/nvim-treesitter', + + -- automatically close html-tags + { + 'windwp/nvim-ts-autotag', + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + }, + + -- folding improvements + { + 'kevinhwang91/nvim-ufo', + dependencies = { 'kevinhwang91/promise-async' }, + }, + + -- colorful brackets + 'luochen1990/rainbow', + + -- fuzzy finder + { + 'nvim-telescope/telescope.nvim', + version = '0.1.2', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, + + -- clean up white spaces and empty lines before writing + "mcauley-penney/tidy.nvim", + + -- todo symbols and highlighting + { + 'folke/todo-comments.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, + + -- git wrapper + 'tpope/vim-fugitive', + + -- golang language support + { + 'fatih/vim-go', + ft = { 'go' }, + }, + + -- markdown language support + { + 'preservim/vim-markdown', + ft = { 'markdown' }, + dependencies = { 'godlygeek/tabular' }, + }, + + -- bulk renamer + 'qpkorr/vim-renamer', + + -- additional quote/parantheses funtions + 'tpope/vim-surround', + + -- colorscheme + 'tiyn/vim-tccs', +}) diff --git a/.config/nvim/plugin/colorscheme.lua b/.config/nvim/plugin/colorscheme.lua new file mode 100644 index 0000000..4497d03 --- /dev/null +++ b/.config/nvim/plugin/colorscheme.lua @@ -0,0 +1,3 @@ +-- tiyn/vim-tccs +vim.cmd('colorscheme tccs') +vim.api.nvim_set_hl(0, 'colorcolumn', { bg = '#772222' }) diff --git a/.config/nvim/plugin/gitsigns.lua b/.config/nvim/plugin/gitsigns.lua new file mode 100644 index 0000000..fa23a5e --- /dev/null +++ b/.config/nvim/plugin/gitsigns.lua @@ -0,0 +1,2 @@ +-- lewis6991/gitsigns.nvim +require('gitsigns').setup() diff --git a/.config/nvim/plugin/indent-blankline.lua b/.config/nvim/plugin/indent-blankline.lua new file mode 100644 index 0000000..1b9afa3 --- /dev/null +++ b/.config/nvim/plugin/indent-blankline.lua @@ -0,0 +1,6 @@ +-- lukas-reineke/indent-blankline.nvim + +require("indent_blankline").setup { + show_current_context = true, + show_current_context_start = true, +} diff --git a/.config/nvim/plugin/lualine.lua b/.config/nvim/plugin/lualine.lua new file mode 100644 index 0000000..6ccbf7e --- /dev/null +++ b/.config/nvim/plugin/lualine.lua @@ -0,0 +1,47 @@ +-- nvim-lualine/lualine.nvim +require('lualine').setup { + options = { + icons_enabled = true, + symbols = { + error = ' ', + warn = ' ', + hint = ' ', + info = ' ', + }, + theme = 'tccs', + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { 'filename' }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} diff --git a/.config/nvim/plugin/neotex.lua b/.config/nvim/plugin/neotex.lua new file mode 100644 index 0000000..efafbb0 --- /dev/null +++ b/.config/nvim/plugin/neotex.lua @@ -0,0 +1,2 @@ +-- donRaphaco/neotex +vim.g.neotex_enabled = 2 diff --git a/.config/nvim/plugin/nvim-autopairs.lua b/.config/nvim/plugin/nvim-autopairs.lua new file mode 100644 index 0000000..ba62d44 --- /dev/null +++ b/.config/nvim/plugin/nvim-autopairs.lua @@ -0,0 +1 @@ +require("nvim-autopairs").setup {} diff --git a/.config/nvim/plugin/nvim-cmp.lua b/.config/nvim/plugin/nvim-cmp.lua new file mode 100644 index 0000000..488317d --- /dev/null +++ b/.config/nvim/plugin/nvim-cmp.lua @@ -0,0 +1,205 @@ +-- hrsh7th/nvim-cmp +local cmp = require("cmp") +local luasnip = require("luasnip") +require("luasnip.loaders.from_snipmate").lazy_load() + +cmp.setup { + sorting = { + comparators = { + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + require "cmp-under-comparator".under, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + } + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'buffer' }, + { name = 'luasnip' }, + }, + formatting = { + format = require("lspkind").cmp_format({ + mode = "symbol_text", + preset = "codicons", + maxwidth = 50, + menu = { + nvim_lsp = "[LSP]", + path = "[PATH]", + buffer = "[BUF]", + luasnip = "[SNIP]", + }, + symbol_map = { + Text = "", + Method = "", + Function = "φ", + Constructor = "", + Field = "■", + Variable = "β", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "π", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "" + }, + }), + }, +} + +-- jose-elias-alvarez/null-ls.nvim +local null_ls = require("null-ls") + +null_ls.setup({ + sources = { + require("null-ls-embedded").nls_source.with({ + filetypes = { "markdown" }, + }), + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.mdformat, + }, +}) + +-- williamboman/mason.nvim +require("mason").setup() + +-- williamboman/mason-lspconfig.nvim +require("mason-lspconfig").setup({ + automatic_setup = true, + ensure_installed = { "pyright", "bashls", "texlab", "nimls", "marksman", "jdtls", "lua_ls" } +}) + +-- jay-babu/mason-null-ls.nvim +require("mason-null-ls").setup({ + automatic_installation = true, + ensure_installed = {} +}) + +-- ray-x/lsp_signature.nvim +require "lsp_signature".setup({ + bind = true, + handler_opts = { + border = "none" + }, + hint_prefix = " ", + hint_scheme = "DiagnosticSignHint", +}) + +-- smiteshp/nvim-navbuddy +local navbuddy = require("nvim-navbuddy") + +-- hrsh7th/cmp-nvim-lsp +local cmp_nvim_lsp = require("cmp_nvim_lsp") + +-- neovim/nvim-lspconfig +local nvim_lsp = require('lspconfig') + +local servers = { "pyright", "bashls", "texlab", "nimls", "marksman" } + +local attach_func = function(client, bufnr) + navbuddy.attach(client, bufnr) +end + +local capabilities = cmp_nvim_lsp.default_capabilities() +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true +} + +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = attach_func, + capabilities = capabilities, + flags = { + debounce_text_changes = 150 + } + } +end + +require 'lspconfig'.jdtls.setup { + on_attach = attach_func, + capabilities = capabilities, + flags = { + debounce_text_changes = 150 + }, + cmd = { 'jdtls' } +} + +require 'lspconfig'.lua_ls.setup { + on_attach = attach_func, + capabilities = capabilities, + settings = { + Lua = { + runtime = { version = 'LuaJIT' }, + diagnostics = { globals = { 'vim' } }, + workspace = { library = vim.api.nvim_get_runtime_file("", true) }, + telemetry = { enable = false }, + }, + }, +} + +require('ufo').setup() + +vim.fn.sign_define( + "DiagnosticSignError", + { texthl = "DiagnosticSignError", text = " ", numhl = "DiagnosticSignError" } +) +vim.fn.sign_define( + "DiagnosticSignWarn", + { texthl = "DiagnosticSignWarn", text = " ", numhl = "DiagnosticSignWarn" } +) +vim.fn.sign_define( + "DiagnosticSignInfo", + { texthl = "DiagnosticSignInfo", text = " ", numhl = "DiagnosticSignInfo" } +) +vim.fn.sign_define( + "DiagnosticSignHint", + { texthl = "DiagnosticSignHint", text = " ", numhl = "DiagnosticSignHint" } +) diff --git a/.config/nvim/plugin/nvim-colorizer.lua b/.config/nvim/plugin/nvim-colorizer.lua new file mode 100644 index 0000000..87abf97 --- /dev/null +++ b/.config/nvim/plugin/nvim-colorizer.lua @@ -0,0 +1,5 @@ +-- norcalli/nvim-colorizer.lua +require 'colorizer'.setup { + '*', + '!markdown', +} diff --git a/.config/nvim/plugin/nvim-tree.lua b/.config/nvim/plugin/nvim-tree.lua new file mode 100644 index 0000000..c792c35 --- /dev/null +++ b/.config/nvim/plugin/nvim-tree.lua @@ -0,0 +1,14 @@ +-- nvim-tree/nvim-tree.lua + +require("nvim-tree").setup({ + sort_by = "case_sensitive", + view = { + width = 30, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, +}) diff --git a/.config/nvim/plugin/nvim-treesitter.lua b/.config/nvim/plugin/nvim-treesitter.lua new file mode 100644 index 0000000..e16154a --- /dev/null +++ b/.config/nvim/plugin/nvim-treesitter.lua @@ -0,0 +1,19 @@ +-- nvim-treesitter/nvim-treesitter + +local ts_config = require "nvim-treesitter.configs" + +ts_config.setup { + ensure_installed = { + "bash", + "c", + "cpp", + "css", + "html", + "java", + "markdown", + "latex", + "python", + }, + + autotag = { enable = true }, +} diff --git a/.config/nvim/plugin/rainbow.lua b/.config/nvim/plugin/rainbow.lua new file mode 100644 index 0000000..837e990 --- /dev/null +++ b/.config/nvim/plugin/rainbow.lua @@ -0,0 +1,2 @@ +-- luochen1990/rainbow +vim.g.rainbow_active = 1 diff --git a/.config/nvim/plugin/telescope.lua b/.config/nvim/plugin/telescope.lua new file mode 100644 index 0000000..b86e5c1 --- /dev/null +++ b/.config/nvim/plugin/telescope.lua @@ -0,0 +1,17 @@ +require("telescope").setup { + extensions = { + file_browser = { + theme = "ivy", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + ["i"] = { + -- your custom insert mode mappings + }, + ["n"] = { + -- your custom normal mode mappings + }, + }, + }, + }, +} diff --git a/.config/nvim/plugin/tidy.lua b/.config/nvim/plugin/tidy.lua new file mode 100644 index 0000000..c5f6e38 --- /dev/null +++ b/.config/nvim/plugin/tidy.lua @@ -0,0 +1,5 @@ +-- mcauley-penney/tidy.nvim + +require("tidy").setup({ + filetype_exclude = {}, +}) diff --git a/.config/nvim/plugin/todo-comments.lua b/.config/nvim/plugin/todo-comments.lua new file mode 100644 index 0000000..dd2fc59 --- /dev/null +++ b/.config/nvim/plugin/todo-comments.lua @@ -0,0 +1,62 @@ +-- folke/todo-comments.nvim + +require 'todo-comments'.setup { + signs = true, -- show icons in the signs column + sign_priority = 8, -- sign priority + -- keywords recognized as todo comments + keywords = { + ERRO = { icon = " ", color = "error" }, + WARN = { icon = " ", color = "warning" }, + HACK = { icon = " ", color = "warning" }, + HINT = { icon = " ", color = "hint" }, + TODO = { icon = " ", color = "hint" }, + INFO = { icon = " ", color = "info", alt = { "NOTE" } }, + PERF = { icon = " ", color = "perfect" }, + TEST = { icon = " ", color = "test" }, + }, + gui_style = { + fg = "NONE", -- The gui style to use for the fg highlight group. + bg = "BOLD", -- The gui style to use for the bg highlight group. + }, + merge_keywords = true, -- when true, custom keywords will be merged with the defaults + -- highlighting of the line containing the todo comment + -- * before: highlights before the keyword (typically comment characters) + -- * keyword: highlights of the keyword + -- * after: highlights after the keyword (todo text) + highlight = { + multiline = true, -- enable multine todo comments + multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword + multiline_context = 10, -- extra lines that will be re-evaluated when changing a line + before = "", -- "fg" or "bg" or empty + keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg) + after = "fg", -- "fg" or "bg" or empty + pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex) + comments_only = true, -- uses treesitter to match keywords in comments only + max_line_len = 400, -- ignore lines longer than this + exclude = {}, -- list of file types to exclude highlighting + }, + -- list of named colors where we try to extract the guifg from the + -- list of highlight groups or use the hex color if hl not found as a fallback + colors = { + error = { "DiagnosticSignError", "ErrorMsg", "#DC2626" }, + warning = { "DiagnosticSignWarn", "WarningMsg", "#FBBF24" }, + hint = { "DiagnosticSignHint", "#10B981" }, + info = { "DiagnosticSignInfo", "#999999" }, + perfect = { "Special", "#FF00FF" }, + test = { "Identifier", "#00dddd" } + }, + search = { + command = "rg", + args = { + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + }, + -- regex that will be used to match keywords. + -- don't replace the (KEYWORDS) placeholder + pattern = [[\b(KEYWORDS):]], -- ripgrep regex + -- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives + }, +} diff --git a/.config/nvim/plugin/vim-go.lua b/.config/nvim/plugin/vim-go.lua new file mode 100644 index 0000000..0eb49ab --- /dev/null +++ b/.config/nvim/plugin/vim-go.lua @@ -0,0 +1,2 @@ +-- fatih/vim-go +vim.g.go_def_mapping_enabled = 0 diff --git a/.config/nvim/plugin/vim-markdown.lua b/.config/nvim/plugin/vim-markdown.lua new file mode 100644 index 0000000..78bedf0 --- /dev/null +++ b/.config/nvim/plugin/vim-markdown.lua @@ -0,0 +1,3 @@ +-- preservim/vim-markdown +vim.g.vim_markdown_folding_style_pythonic = 1 +vim.g.vim_markdown_folding_disabled = 1 diff --git a/.config/nvim/snippets/python.snippets b/.config/nvim/snippets/python.snippets new file mode 100644 index 0000000..9b70abf --- /dev/null +++ b/.config/nvim/snippets/python.snippets @@ -0,0 +1,199 @@ +# shbang 3 +snippet #! + #!/usr/bin/env python3 + +# shbang 2 +snippet #!2 + #!/usr/bin/env python2 + # -*- coding: utf-8 -*- + +# shbang 3 +snippet #!3 + #!/usr/bin/env python3 + +# import +snippet imp + import ${0:module} + +# from ... import +snippet from + from ${1:package} import ${0:module} + +# while +snippet wh + while ${1:condition}: + ${0:${VISUAL}} + +# do ... while +snippet dowh + while True: + ${1} + if ${0:condition}: + break + +# with +snippet with + with ${1:expr} as ${2:var}: + ${0:${VISUAL}} + +# async with +snippet awith + async with ${1:expr} as ${2:var}: + ${0:${VISUAL}} + +# class +snippet cla + class ${1:class_name}: + """${0:description}""" + +# class with init +snippet clai + class ${1:class_name}: + """${2:description}""" + def __init__(self, ${3:args}): + ${0} + +# function with docstring +snippet def + def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + """${3:docstring for $1}""" + ${0} + +# function +snippet deff + def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + ${0} + +# async function with docstring +snippet adef + async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + """${3:docstring for $1}""" + ${0} + +# async function +snippet adeff + async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + ${0} + +# init function +snippet defi + def __init__(self, ${1:args}): + ${0} +# if +snippet if + if ${1:condition}: + ${0:${VISUAL}} + +# else +snippet el + else: + ${0:${VISUAL}} + +# else if +snippet ei + elif ${1:condition}: + ${0:${VISUAL}} + +# for +snippet for + for ${1:item} in ${2:items}: + ${0} + +# return +snippet ret + return ${0} + +# self reference +snippet . + self. + +# self attribute +snippet sa self.attribute = attribute + self.${1:attribute} = $1 + +# try ... except +snippet try Try/Except + try: + ${1:${VISUAL}} + except ${2:Exception} as ${3:e}: + ${0:raise $3} + +# try ... except ... else +snippet trye Try/Except/Else + try: + ${1:${VISUAL}} + except ${2:Exception} as ${3:e}: + ${4:raise $3} + else: + ${0} + +# try ... except ... finally +snippet tryf Try/Except/Finally + try: + ${1:${VISUAL}} + except ${2:Exception} as ${3:e}: + ${4:raise $3} + finally: + ${0} + +# try ... except ... else ... finally +snippet tryef Try/Except/Else/Finally + try: + ${1:${VISUAL}} + except ${2:Exception} as ${3:e}: + ${4:raise $3} + else: + ${5} + finally: + ${0} + +# if name is main +snippet ifmain + if __name__ == '__main__': + ${0:main()} + +# docstring +snippet " + """${0:doc} + """ + +# test function +snippet test + def test_${1:description}(${2:`indent('.') ? 'self' : ''`}): + ${0} + +# list comprehension +snippet lcp list comprehension + [${1} for ${2} in ${3:${VISUAL}}]${0} + +# dict comprehension +snippet dcp dict comprehension + {${1}: ${2} for ${3} in ${4:${VISUAL}}}${0} + +# set comprehension +snippet scp set comprehension + {${1} for ${2} in ${3:${VISUAL}}}${0} + +# print +snippet pr + print($0) + +# print string +snippet prs + print("$0") + +# fprint string +snippet prf + print(f"$0") + +# print to file +snippet fpr + print($0, file=${1:sys.stderr}) + +# print string to file +snippet fprs + print("$0", file=${1:sys.stderr}) + +# fprint string to file +snippet fprf + print(f"$0", file=${1:sys.stderr}) diff --git a/.config/nvim/snippets/tex.snippets b/.config/nvim/snippets/tex.snippets new file mode 100644 index 0000000..f391aae --- /dev/null +++ b/.config/nvim/snippets/tex.snippets @@ -0,0 +1,257 @@ +# documentclass without options +snippet dcl \documentclass{} + \\documentclass{${1:class}} ${0} + +# documentclass with options +snippet dclo \documentclass[]{} + \\documentclass[${1:options}]{${2:class}} ${0} + +# newcommand +snippet nc \newcommand + \\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0} + +# usepackage +snippet up \usepackage + \\usepackage[${1:options}]{${2:package}} ${0} + +# \begin{}...\end{} +snippet begin \begin{} ... \end{} block + \\begin{${1:env}} + ${0:${VISUAL}} + \\end{$1} + +# maketitle +snippet mkt maketitle + \\maketitle + +# tabular +snippet tab tabular (or arbitrary) environment + \\begin{${1:tabular}}{${2:c}} + ${0:${VISUAL}} + \\end{$1} + +snippet center center environment + \\begin{center} + ${0:${VISUAL}} + \\end{center} + +# align(ed) +snippet ali align(ed) environment + \\begin{align${1:ed}} + \\label{eq:${2}} + ${0:${VISUAL}} + \\end{align$1} + +# equation +snippet eq equation environment + \\begin{equation} + ${0:${VISUAL}} + \\end{equation} + +# equation +snippet eql Labeled equation environment + \\begin{equation} + \\label{eq:${2}} + ${0:${VISUAL}} + \\end{equation} + +# equation +snippet eq* unnumbered equation environment + \\begin{equation*} + ${0:${VISUAL}} + \\end{equation*} + +# label +snippet lab \label + \\label{${1:eq:}${2:fig:}${3:tab:}${0}} + +# enumerate +snippet enum enumerate environment + \\begin{enumerate} + \\item ${0} + \\end{enumerate} + +# itemize +snippet item itemize environment + \\begin{itemize} + \\item ${0} + \\end{itemize} + +# item +snippet it \item + \\item ${1:${VISUAL}} + +# endless new item +snippet ]i \item (recursive) + \\item ${1} + ${0:]i} + +# matrix +snippet mat smart matrix environment + \\begin{${1:p/b/v/V/B/small}matrix} + ${0:${VISUAL}} + \\end{$1matrix} + +# chapter +snippet cha \chapter + \\chapter{${1:chapter name}}% + \\label{cha:${2:$1}} + ${0} + +# section +snippet sec \section + \\section{${1:section name}}% + \\label{sec:${2:$1}} + ${0} + +# section without number +snippet sec* \section* + \\section*{${1:section name}}% + \\label{sec:${2:$1}} + ${0} + +# sub section +snippet sub \subsection + \\subsection{${1:subsection name}}% + \\label{sub:${2:$1}} + ${0} + +# sub section without number +snippet sub* \subsection* + \\subsection*{${1:subsection name}}% + \\label{sub:${2:$1}} + ${0} + +# sub sub section +snippet ssub \subsubsection + \\subsubsection{${1:subsubsection name}}% + \\label{ssub:${2:$1}} + ${0} + +# sub sub section without number +snippet ssub* \subsubsection* + \\subsubsection*{${1:subsubsection name}}% + \\label{ssub:${2:$1}} + ${0} + +# paragraph +snippet par \paragraph + \\paragraph{${1:paragraph name}}% + \\label{par:${2:$1}} + ${0} + +# sub paragraph +snippet subp \subparagraph + \\subparagraph{${1:subparagraph name}}% + \\label{subp:${2:$1}} + ${0} + +# text italic +snippet ita italic text + \\textit{${1:${VISUAL:text}}}${0} + +# text bold +snippet bf bold face text + \\textbf{${1:${VISUAL:text}}}${0} + +# text underline +snippet under underline text + \\underline{${1:${VISUAL:text}}}${0} + +# text overline +snippet over overline text + \\overline{${1:${VISUAL:text}}}${0} + +# text emphasize +snippet emp emphasize text + \\emph{${1:${VISUAL:text}}}${0} + +# text small caps +snippet sc small caps text + \\textsc{${1:${VISUAL:text}}}${0} + +# text sans serife +snippet sf sans serife text + \\textsf{${1:${VISUAL:text}}}${0} + +# text roman +snippet rm roman font text + \\textrm{${1:${VISUAL:text}}}${0} + +# text typewriter +snippet tt typewriter (monospace) text + \\texttt{${1:${VISUAL:text}}}${0} + +# text subscripted +snippet tsub subscripted text + \\textsubscript{${1:${VISUAL:text}}}${0} + +# text superscripted +snippet tsup superscripted text + \\textsuperscript{${1:${VISUAL:text}}}${0} + +# footnote +snippet ft \footnote + \\footnote{${1:${VISUAL:text}}}${0} + +# figure includegraphics +snippet fig figure environment (includegraphics) + \\begin{figure}[htpb] + \\begin{center} + \\includegraphics[scale=${1}]{Figures/${2}} + \\end{center} + \\caption{${3}} + \\label{fig:${4}} + \\end{figure} + ${0} + +# figure tikz +snippet tikz figure environment (tikzpicture) + \\begin{figure}[htpb] + \\begin{center} + \\begin{tikzpicture}[scale=${1:1}, transform shape] + ${2} + \\end{tikzpicture} + \\end{center} + \\caption{${3}}% + \\label{fig:${4}} + \\end{figure} + ${0} + +# math fraction +snippet frac \frac{}{} + \\frac{${1:num}}{${2:denom}} ${0} + +# math sum +snippet sum \sum^{}_{} + \\sum^{${1:n}}_{${2:i=1}} ${0} + +# math limes +snippet lim \lim_{} + \\lim_{${1:n \\to \\infty}} ${0} + +# code listing +snippet lst + \\begin{listing}[language=${1:language}] + ${0:${VISUAL}} + \\end{listing} + +# code listing inline +snippet lsi + \\lstinline|${1}| ${0} + +# hyperlink url +snippet url + \\url{${1}} ${0} + +# hyperlink href +snippet href + \\href{${1}}{${2}} ${0} + +# right arrow +snippet ra rightarrow + \\rightarrow {$0} + +# long right arrow +snippet lra longrightarrow + \\longrightarrow {$0}