diff --git a/alacritty/.config/alacritty/alacritty.yml b/alacritty/.config/alacritty/alacritty.yml index 2095be5..2ca0bb1 100644 --- a/alacritty/.config/alacritty/alacritty.yml +++ b/alacritty/.config/alacritty/alacritty.yml @@ -118,7 +118,7 @@ font: # - (macOS) Menlo # - (Linux/BSD) monospace # - (Windows) Consolas - family: Victor Mono + family: VictorMono Nerd Font Mono # The `style` can be specified to pick a specific face. style: Medium @@ -129,7 +129,7 @@ font: # # If the bold family is not specified, it will fall back to the # value specified for the normal font. - family: Victor Mono + family: VictorMono Nerd Font Mono # The `style` can be specified to pick a specific face. style: Bold @@ -140,7 +140,7 @@ font: # # If the italic family is not specified, it will fall back to the # value specified for the normal font. - famaly: Victor Mono + family: VictorMono Nerd Font Mono # The `style` can be specified to pick a specific face. style: Medium Italic @@ -151,7 +151,7 @@ font: # # If the bold italic family is not specified, it will fall back to the # value specified for the normal font. - family: Victor Mono + family: VictorMono Nerd Font Mono # The `style` can be specified to pick a specific face. style: Bold Italic diff --git a/nvim/.config/nvim/coc-settings.json b/nvim/.config/nvim/coc-settings.json deleted file mode 100644 index 6df9707..0000000 --- a/nvim/.config/nvim/coc-settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "coc.preferences.formatOnSaveFiletypes": ["javascript", "json", "rust"] -} diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..5639673 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,22 @@ +require "user.impatient" +require "user.options" +require "user.keymaps" +require "user.plugins" +require "user.autocommands" +require "user.colorscheme" +require "user.cmp" +require "user.telescope" +require "user.gitsigns" +require "user.treesitter" +require "user.autopairs" +require "user.comment" +require "user.nvim-tree" +require "user.bufferline" +require "user.lualine" +require "user.toggleterm" +require "user.project" +require "user.illuminate" +require "user.indentline" +require "user.alpha" +require "user.lsp" +require "user.dap" diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim deleted file mode 100644 index 82044dc..0000000 --- a/nvim/.config/nvim/init.vim +++ /dev/null @@ -1,399 +0,0 @@ -" Fish doesn't play all that well with others -set shell=/bin/bash -let mapleader = "\" - -set nocompatible -filetype off - -call plug#begin('~/.nvim/plugged') - -" Semantic language support -" Collection of common configurations for the Nvim LSP client -Plug 'neovim/nvim-lspconfig' -Plug 'simrat39/rust-tools.nvim' -Plug 'nvim-lua/lsp_extensions.nvim' -" LSP completion source for nvim-cmp -Plug 'hrsh7th/cmp-nvim-lsp', {'branch': 'main'} -" Other usefull completion sources -Plug 'hrsh7th/cmp-buffer', {'branch': 'main'} -Plug 'hrsh7th/cmp-path', {'branch': 'main'} -" Completion framework -Plug 'hrsh7th/nvim-cmp', {'branch': 'main'} -Plug 'ray-x/lsp_signature.nvim' -" Snippet completion source for nvim-cmp -Plug 'hrsh7th/cmp-vsnip', {'branch': 'main'} -Plug 'hrsh7th/vim-vsnip' - -" GUI enhancements -Plug 'andymass/vim-matchup' - -" Syntactic language support -Plug 'cespare/vim-toml' -Plug 'stephpy/vim-yaml' -Plug 'rust-lang/rust.vim' -Plug 'rhysd/vim-clang-format' -Plug 'dag/vim-fish' -Plug 'godlygeek/tabular' -Plug 'plasticboy/vim-markdown' - -" Debugging -Plug 'nvim-lua/plenary.nvim' -Plug 'mfussenegger/nvim-dap' - -Plug 'junegunn/goyo.vim' -Plug 'junegunn/limelight.vim' -Plug 'ap/vim-css-color', { 'for': ['javascript', 'css', 'html'] } -" Switch working directory based on git root -Plug 'airblade/vim-rooter' -" Fuzzy finder -Plug 'srstevenson/vim-picker' - -Plug 'sheerun/vim-polyglot' -Plug 'tpope/vim-repeat' -Plug 'tpope/vim-sleuth' -Plug 'tpope/vim-surround' -Plug 'tpope/vim-unimpaired' - - -" Plug 'neoclide/coc.nvim', {'branch': 'release'} " :CocInstall coc-tsserver coc-json coc-eslint coc-prettier -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} -Plug 'jeetsukumaran/vim-pythonsense' -Plug 'Vimjas/vim-python-pep8-indent' - -Plug 'lifepillar/vim-solarized8' -Plug 'sainnhe/gruvbox-material' - -call plug#end() - -if has('nvim') - set guicursor=n-v-c:block-Cursor/lCursor-blinkon0,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor - set inccommand=nosplit - noremap :confirm qall -end - -""" LSP -" LSP configuration -lua << END -local cmp = require'cmp' - -local lspconfig = require'lspconfig' -cmp.setup({ -snippet = { - -- REQUIRED by nvim-cmp. get rid of it once we can - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -end, -}, - mapping = { - -- Tab immediately completes. C-n/C-p to select. - [''] = cmp.mapping.confirm({ select = true }) - }, - sources = cmp.config.sources({ - -- TODO: currently snippets from lsp end up getting prioritized -- stop that! - { name = 'nvim_lsp' }, - }, { - { name = 'path' }, - }), -experimental = { - ghost_text = true, - }, -}) - --- Enable completing paths in : -cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }) -}) - --- Setup lspconfig. -local on_attach = function(client, bufnr) -local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end -local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - ---Enable completion triggered by -buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - --- Mappings. -local opts = { noremap=true, silent=true } - --- See `:help vim.lsp.*` for documentation on any of the below functions -buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) -buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) -buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) -buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) -buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) -buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) -buf_set_keymap('n', 'r', 'lua vim.lsp.buf.rename()', opts) -buf_set_keymap('n', 'a', 'lua vim.lsp.buf.code_action()', opts) -buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) -buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) -buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) -buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) -buf_set_keymap('n', 'q', 'lua vim.diagnostic.set_loclist()', opts) -buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) - --- Get signatures (and _only_ signatures) when in argument lists. -require "lsp_signature".on_attach({ -doc_lines = 0, -handler_opts = { - border = "none" - }, -}) -end - --- Update this path -local extension_path = vim.env.HOME .. '/.vscode/extensions/vadimcn.vscode-lldb-1.7.0/' -local codelldb_path = extension_path .. 'adapter/codelldb' -local liblldb_path = extension_path .. 'lldb/lib/liblldb.dylib' - -local opts = { - -- ... other configs - dap = { - adapter = require('rust-tools.dap').get_codelldb_adapter( - codelldb_path, liblldb_path) - } -} - --- Normal setup -require('rust-tools').setup(opts) - -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( -vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = true, - signs = true, - update_in_insert = true, - } -) -END - -" Enable type inlay hints -autocmd CursorHold,CursorHoldI *.rs :lua require'lsp_extensions'.inlay_hints{ only_current_line = true } - -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -set signcolumn=yes - -if executable('ag') - set grepprg=ag\ --nogroup\ --nocolor -endif -if executable('rg') - set grepprg=rg\ --no-heading\ --vimgrep - set grepformat=%f:%l:%c:%m -endif - - -" rust -let g:rustfmt_autosave = 1 -let g:rustfmt_emit_files = 1 -let g:rustfmt_fail_silently = 0 -let g:rust_clip_command = 'xclip -selection clipboard' - -" Completion -" Better completion -" 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 -" Better display for messages -set cmdheight=2 -" You will have bad experience for diagnostic messages when it's default 4000. -set updatetime=300 - -" ============================================================================= -" # GUI settings -" ============================================================================= -set guioptions-=T " Remove toolbar -set vb t_vb= " No more beeps -set backspace=2 " Backspace over newlines -set nofoldenable -set ttyfast -" https://github.com/vim/vim/issues/1735#issuecomment-383353563 -set lazyredraw -set synmaxcol=500 -set laststatus=2 -set relativenumber " Relative line numbers -set number " Also show current absolute line -set diffopt+=iwhite " No whitespace in vimdiff -" Make diffing better: https://vimways.org/2018/the-power-of-diff/ -set diffopt+=algorithm:patience -set diffopt+=indent-heuristic -set colorcolumn=80 " and give me a colored column -set showcmd " Show (partial) command in status line. -set mouse=a " Enable mouse usage (all modes) in terminals -set shortmess+=c " don't give |ins-completion-menu| messages. - -" Show those damn hidden characters -" Verbose: set listchars=nbsp:¬,eol:¶,extends:»,precedes:«,trail:• -set listchars=nbsp:¬,extends:»,precedes:«,trail:• - -" Enable file type detection -filetype plugin indent on - -"http://stackoverflow.com/questions/526858/ -" set emacs-style tab completing when selecting files, etc -"Make vim do normal bash like tab completion for file names -"set wildmode=longest,list,full -set wildmode=longest,list,full -set wildmenu -" Fix slow O inserts -:set timeout timeoutlen=1000 ttimeoutlen=100 -" Normally, Vim messes with iskeyword when you open a shell file. This can -" leak out, polluting other file types even after a 'set ft=' change. This -" variable prevents the iskeyword change so it can't hurt anyone. -let g:sh_noisk=1 -" Modelines (comments that set vim options on a per-file basis) -set modeline -set modelines=3 -" Turn folding off for real, hopefully -set foldmethod=manual -" Insert only one space when joining lines that contain sentence-terminating -" punctuation like `.`. -set nojoinspaces -" If a file is changed outside of vim, automatically reload it without asking -set autoread - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" COLOURS -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -if exists('+termguicolors') - let &t_8f = "\[38;2;%lu;%lu;%lum" - let &t_8b = "\[48;2;%lu;%lu;%lum" - set termguicolors - let g:solarized_termtrans=0 -endif - -set background=dark -colorscheme gruvbox-material -syntax on -hi Normal ctermbg=NONE - -""" Fuzzy finder -nmap f :call picker#File('find . -type f', 'edit') -nmap g (PickerEdit) -nmap b (PickerBuffer) - -function! MapCR() - nnoremap :nohlsearch -endfunction -call MapCR() - -augroup vimrcEX - "Clear all autocmds in the group - autocmd! - autocmd Filetype text setlocal textwidth=78 - " Jump to last cursor position unless it's invalid or in an event handler - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal g`\"" | - \ endif - - " Leave the return key alone when in command line " windows, since it's used - " to run commands there. - autocmd! CmdwinEnter * :unmap - autocmd! CmdwinLeave * :call MapCR() - - " *.md is markdown - autocmd! BufNewFile,BufRead *.md setlocal ft= -augroup END - -" Move around splits with -nnoremap j -nnoremap k -nnoremap h -nnoremap l - -inoremap <- -inoremap -! - -map :echo "no!" -map :echo "no!" -map :echo "no!" -map :echo "no!" - -" Move through buffers like OS X tabs -map L :bnext -map H :bprevious -"map L :next -"map H :prev -"map :bnext -"map :bprevious -"map :bnext -"map :bprevious -"noremap ] :bnext -"noremap [ :bprevious -autocmd! bufwritepost init.vim source % - -" 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 - -" Setup Completion -" See https://github.com/hrsh7th/nvim-cmp#basic-configuration -lua <'] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - -- Add tab support - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }) - }, - --- Installed sources -sources = { - { name = 'nvim_lsp' }, - { name = 'vsnip' }, - { name = 'path' }, - { name = 'buffer' }, - }, -}) -EOF -autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 200) - - -" Create non-existing dir on save -function! s:MkNonExDir(file, buf) - if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' - let dir=fnamemodify(a:file, ':h') - if !isdirectory(dir) - call mkdir(dir, 'p') - endif - endif -endfunction -augroup BWCCreateDir - autocmd! - autocmd BufWritePre * :call s:MkNonExDir(expand(''), +expand('')) -augroup END - -" Follow Rust code style rules -au Filetype rust source ~/.config/nvim/scripts/spacetab.vim -au Filetype rust set colorcolumn=100 - -" Permanent undo -set undodir=~/.nvimdid -set undofile - -let g:rooter_patterns = ['.git'] diff --git a/nvim/.config/nvim/lua/user/alpha.lua b/nvim/.config/nvim/lua/user/alpha.lua new file mode 100644 index 0000000..952b5c8 --- /dev/null +++ b/nvim/.config/nvim/lua/user/alpha.lua @@ -0,0 +1,35 @@ +local status_ok, alpha = pcall(require, "alpha") +if not status_ok then + return +end + +local dashboard = require "alpha.themes.dashboard" +dashboard.section.header.val = { + [[ __ ]], + [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], + [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], + [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], + [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], + [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], +} +dashboard.section.buttons.val = { + dashboard.button("f", " " .. " Find file", ":Telescope find_files "), + dashboard.button("e", " " .. " New file", ":ene startinsert "), + dashboard.button("p", " " .. " Find project", ":lua require('telescope').extensions.projects.projects()"), + dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), + dashboard.button("t", " " .. " Find text", ":Telescope live_grep "), + dashboard.button("c", " " .. " Config", ":e $MYVIMRC "), + dashboard.button("q", " " .. " Quit", ":qa"), +} +local function footer() + return "Your mom doesn't work here" +end + +dashboard.section.footer.val = footer() + +dashboard.section.footer.opts.hl = "Type" +dashboard.section.header.opts.hl = "Include" +dashboard.section.buttons.opts.hl = "Keyword" + +dashboard.opts.opts.noautocmd = true +alpha.setup(dashboard.opts) diff --git a/nvim/.config/nvim/lua/user/autocommands.lua b/nvim/.config/nvim/lua/user/autocommands.lua new file mode 100644 index 0000000..2559e20 --- /dev/null +++ b/nvim/.config/nvim/lua/user/autocommands.lua @@ -0,0 +1,66 @@ +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "qf", "help", "man", "lspinfo", "spectre_panel" }, + callback = function() + vim.cmd([[ + nnoremap q :close + set nobuflisted + ]]) + end, +}) + +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif") + +vim.api.nvim_create_autocmd({ "VimResized" }, { + callback = function() + vim.cmd("tabdo wincmd =") + end, +}) + +vim.api.nvim_create_autocmd({ "CmdWinEnter" }, { + callback = function() + vim.cmd("quit") + end, +}) + +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + callback = function() + vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) + end, +}) + +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = { "*.java" }, + callback = function() + vim.lsp.codelens.refresh() + end, +}) + +vim.api.nvim_create_autocmd({ "VimEnter" }, { + callback = function() + vim.cmd("hi link illuminatedWord LspReferenceText") + end, +}) + +vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + callback = function() + local line_count = vim.api.nvim_buf_line_count(0) + if line_count >= 5000 then + vim.cmd("IlluminatePauseBuf") + end + end, +}) + +-- vim.api.nvim_create_autocmd({ "BufWritePost" }, { +-- pattern = { "*.rs" }, +-- callback = function() +-- vim.lsp.codelens.refresh() +-- end, +-- }) diff --git a/nvim/.config/nvim/lua/user/autocommands.lua.orig b/nvim/.config/nvim/lua/user/autocommands.lua.orig new file mode 100644 index 0000000..3d91968 --- /dev/null +++ b/nvim/.config/nvim/lua/user/autocommands.lua.orig @@ -0,0 +1,83 @@ +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "qf", "help", "man", "lspinfo", "spectre_panel" }, + callback = function() + vim.cmd([[ + nnoremap q :close + set nobuflisted + ]]) + end, +}) + +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif") + +vim.api.nvim_create_autocmd({ "VimResized" }, { + callback = function() + vim.cmd("tabdo wincmd =") + end, +}) + +vim.api.nvim_create_autocmd({ "CmdWinEnter" }, { + callback = function() + vim.cmd("quit") + end, +}) + +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + callback = function() + vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) + end, +}) + +<<<<<<< HEAD +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = { "*.java" }, + callback = function() + vim.lsp.codelens.refresh() + end, +}) + +vim.api.nvim_create_autocmd({ "VimEnter" }, { + callback = function() + vim.cmd("hi link illuminatedWord LspReferenceText") + end, +}) + +vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + callback = function() + local line_count = vim.api.nvim_buf_line_count(0) + if line_count >= 5000 then + vim.cmd("IlluminatePauseBuf") + end + end, +}) + + +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = { "*.rs" }, + callback = function() + vim.lsp.codelens.refresh() + end, +}) +||||||| parent of 8f71431 (that's how you do codelens with rust tools) +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = { "*.rs" }, + callback = function() + vim.lsp.codelens.refresh() + end, +}) +======= +-- vim.api.nvim_create_autocmd({ "BufWritePost" }, { +-- pattern = { "*.rs" }, +-- callback = function() +-- vim.lsp.codelens.refresh() +-- end, +-- }) +>>>>>>> 8f71431 (that's how you do codelens with rust tools) diff --git a/nvim/.config/nvim/lua/user/autopairs.lua b/nvim/.config/nvim/lua/user/autopairs.lua new file mode 100644 index 0000000..8364c79 --- /dev/null +++ b/nvim/.config/nvim/lua/user/autopairs.lua @@ -0,0 +1,34 @@ +-- Setup nvim-cmp. +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup({ + check_ts = true, -- treesitter integration + disable_filetype = { "TelescopePrompt" }, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + + fast_wrap = { + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, +}) + +local cmp_autopairs = require("nvim-autopairs.completion.cmp") +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({})) diff --git a/nvim/.config/nvim/lua/user/bufferline.lua b/nvim/.config/nvim/lua/user/bufferline.lua new file mode 100644 index 0000000..f22fbcb --- /dev/null +++ b/nvim/.config/nvim/lua/user/bufferline.lua @@ -0,0 +1,103 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + return +end + +bufferline.setup { + options = { + close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, + }, + + highlights = { + fill = { + fg = { attribute = "fg", highlight = "#ff0000" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + background = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + buffer_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + close_button = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + close_button_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + tab_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + tab = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + tab_close = { + -- fg = {attribute='fg',highlight='LspDiagnosticsDefaultError'}, + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + duplicate_selected = { + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "TabLineSel" }, + italic = true, + }, + + duplicate_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + + duplicate = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + + modified = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + modified_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + modified_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + separator = { + fg = { attribute = "bg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + separator_selected = { + fg = { attribute = "bg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + indicator_selected = { + fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/user/cmp.lua b/nvim/.config/nvim/lua/user/cmp.lua new file mode 100644 index 0000000..1eb816b --- /dev/null +++ b/nvim/.config/nvim/lua/user/cmp.lua @@ -0,0 +1,128 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end + +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") +end + +local kind_icons = { + 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 = "", +} + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = 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", + }), + }), + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + vim_item.kind = kind_icons[vim_item.kind] + vim_item.menu = ({ + nvim_lsp = "", + nvim_lua = "", + luasnip = "", + buffer = "", + path = "", + emoji = "", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + }, +}) diff --git a/nvim/.config/nvim/lua/user/colorscheme.lua b/nvim/.config/nvim/lua/user/colorscheme.lua new file mode 100644 index 0000000..12305e7 --- /dev/null +++ b/nvim/.config/nvim/lua/user/colorscheme.lua @@ -0,0 +1,7 @@ +vim.o.background = "light" +local colorscheme = "gruvbox" + +local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) +if not status_ok then + return +end diff --git a/nvim/.config/nvim/lua/user/comment.lua b/nvim/.config/nvim/lua/user/comment.lua new file mode 100644 index 0000000..da49998 --- /dev/null +++ b/nvim/.config/nvim/lua/user/comment.lua @@ -0,0 +1,29 @@ +local status_ok, comment = pcall(require, "Comment") +if not status_ok then + return +end + +comment.setup({ + pre_hook = function(ctx) + -- Only calculate commentstring for tsx filetypes + if vim.bo.filetype == "typescriptreact" then + local U = require("Comment.utils") + + -- Determine whether to use linewise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" + + -- Determine the location where to calculate commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end + + return require("ts_context_commentstring.internal").calculate_commentstring({ + key = type, + location = location, + }) + end + end, +}) diff --git a/nvim/.config/nvim/lua/user/dap.lua b/nvim/.config/nvim/lua/user/dap.lua new file mode 100644 index 0000000..ca8d189 --- /dev/null +++ b/nvim/.config/nvim/lua/user/dap.lua @@ -0,0 +1,75 @@ +local dap_status_ok, dap = pcall(require, "dap") +if not dap_status_ok then + return +end + +local dap_ui_status_ok, dapui = pcall(require, "dapui") +if not dap_ui_status_ok then + return +end + +local dap_install_status_ok, dap_install = pcall(require, "dap-install") +if not dap_install_status_ok then + return +end + +dap_install.setup({}) + +dap_install.config("python", {}) +-- add other configs here + +dapui.setup({ + expand_lines = true, + icons = { expanded = "", collapsed = "", circular = "" }, + mappings = { + -- Use a table to apply multiple mappings + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + layouts = { + { + elements = { + { id = "scopes", size = 0.33 }, + { id = "breakpoints", size = 0.17 }, + { id = "stacks", size = 0.25 }, + { id = "watches", size = 0.25 }, + }, + size = 0.33, + position = "right", + }, + { + elements = { + { id = "repl", size = 0.45 }, + { id = "console", size = 0.55 }, + }, + size = 0.27, + position = "bottom", + }, + }, + floating = { + max_height = 0.9, + max_width = 0.5, -- Floats will be treated as percentage of your screen. + border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded' + mappings = { + close = { "q", "" }, + }, + }, +}) + +vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" }) + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end + +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end + +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end diff --git a/nvim/.config/nvim/lua/user/gitsigns.lua b/nvim/.config/nvim/lua/user/gitsigns.lua new file mode 100644 index 0000000..9453e4f --- /dev/null +++ b/nvim/.config/nvim/lua/user/gitsigns.lua @@ -0,0 +1,36 @@ +local status_ok, gitsigns = pcall(require, "gitsigns") +if not status_ok then + return +end + +gitsigns.setup { + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, +} diff --git a/nvim/.config/nvim/lua/user/illuminate.lua b/nvim/.config/nvim/lua/user/illuminate.lua new file mode 100644 index 0000000..b9e814e --- /dev/null +++ b/nvim/.config/nvim/lua/user/illuminate.lua @@ -0,0 +1,38 @@ +local status_ok, illuminate = pcall(require, "illuminate") +if not status_ok then + return +end + +vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree'} +vim.api.nvim_set_keymap('n', '', 'lua require"illuminate".next_reference{wrap=true}', {noremap=true}) +vim.api.nvim_set_keymap('n', '', 'lua require"illuminate".next_reference{reverse=true,wrap=true}', {noremap=true}) + +illuminate.configure { + providers = { + "lsp", + "treesitter", + "regex", + }, + delay = 200, + filetypes_denylist = { + "dirvish", + "fugitive", + "alpha", + "NvimTree", + "packer", + "neogitstatus", + "Trouble", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "TelescopePrompt", + }, + filetypes_allowlist = {}, + modes_denylist = {}, + modes_allowlist = {}, + providers_regex_syntax_denylist = {}, + providers_regex_syntax_allowlist = {}, + under_cursor = true, +} diff --git a/nvim/.config/nvim/lua/user/impatient.lua b/nvim/.config/nvim/lua/user/impatient.lua new file mode 100644 index 0000000..84419e0 --- /dev/null +++ b/nvim/.config/nvim/lua/user/impatient.lua @@ -0,0 +1,6 @@ +local status_ok, impatient = pcall(require, "impatient") +if not status_ok then + return +end + +impatient.enable_profile() diff --git a/nvim/.config/nvim/lua/user/indentline.lua b/nvim/.config/nvim/lua/user/indentline.lua new file mode 100644 index 0000000..b7389d9 --- /dev/null +++ b/nvim/.config/nvim/lua/user/indentline.lua @@ -0,0 +1,18 @@ +local status_ok, indent_blankline = pcall(require, "indent_blankline") +if not status_ok then + return +end + +indent_blankline.setup { + char = "▏", + show_trailing_blankline_indent = false, + show_first_indent_level = true, + use_treesitter = true, + show_current_context = true, + buftype_exclude = { "terminal", "nofile" }, + filetype_exclude = { + "help", + "packer", + "NvimTree", + }, +} diff --git a/nvim/.config/nvim/lua/user/keymaps.lua b/nvim/.config/nvim/lua/user/keymaps.lua new file mode 100644 index 0000000..a311853 --- /dev/null +++ b/nvim/.config/nvim/lua/user/keymaps.lua @@ -0,0 +1,80 @@ +-- Shorten function name +local keymap = vim.keymap.set +-- Silent keymap option +local opts = { silent = true } + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +-- Normal -- +-- Better window navigation +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +-- Resize with arrows +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +-- Navigate buffers +keymap("n", "", ":bnext", opts) +keymap("n", "", ":bprevious", opts) + +-- Clear highlights +keymap("n", "", "nohlsearch", opts) + +-- Close buffers +keymap("n", "", "Bdelete!", opts) + +-- Better paste +keymap("v", "p", '"_dP', opts) + +-- Insert -- +-- Press jk fast to enter +keymap("i", "jk", "", opts) + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- Plugins -- + +-- NvimTree +keymap("n", "e", ":NvimTreeToggle", opts) + +-- Telescope +keymap("n", "ff", ":Telescope find_files", opts) +keymap("n", "ft", ":Telescope live_grep", opts) +keymap("n", "fp", ":Telescope projects", opts) +keymap("n", "fb", ":Telescope buffers", opts) + +-- Git +keymap("n", "gg", "lua _LAZYGIT_TOGGLE()", opts) + +-- Comment +keymap("n", "/", "lua require('Comment.api').toggle.linewise.current()", opts) +keymap("x", "/", 'lua require("Comment.api").toggle.linewise(vim.fn.visualmode())') + +-- DAP +keymap("n", "db", "lua require'dap'.toggle_breakpoint()", opts) +keymap("n", "dc", "lua require'dap'.continue()", opts) +keymap("n", "di", "lua require'dap'.step_into()", opts) +keymap("n", "do", "lua require'dap'.step_over()", opts) +keymap("n", "dO", "lua require'dap'.step_out()", opts) +keymap("n", "dr", "lua require'dap'.repl.toggle()", opts) +keymap("n", "dl", "lua require'dap'.run_last()", opts) +keymap("n", "du", "lua require'dapui'.toggle()", opts) +keymap("n", "dt", "lua require'dap'.terminate()", opts) diff --git a/nvim/.config/nvim/lua/user/lsp/handlers.lua b/nvim/.config/nvim/lua/user/lsp/handlers.lua new file mode 100644 index 0000000..60967b1 --- /dev/null +++ b/nvim/.config/nvim/lua/user/lsp/handlers.lua @@ -0,0 +1,91 @@ +local M = {} + +local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_cmp_ok then + return +end + +M.capabilities = vim.lsp.protocol.make_client_capabilities() +M.capabilities.textDocument.completion.completionItem.snippetSupport = true +M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities) + +M.setup = function() + local signs = { + + { name = "DiagnosticSignError", text = "" }, + { name = "DiagnosticSignWarn", text = "" }, + { name = "DiagnosticSignHint", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + virtual_text = false, -- disable virtual text + signs = { + active = signs, -- show signs + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + local keymap = vim.api.nvim_buf_set_keymap + keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) + keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) + keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) + keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) + keymap(bufnr, "n", "lf", "lua vim.lsp.buf.format{ async = true }", opts) + keymap(bufnr, "n", "li", "LspInfo", opts) + keymap(bufnr, "n", "lI", "LspInstallInfo", opts) + keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) + keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) + keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) + keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) + keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) + keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.server_capabilities.documentFormattingProvider = false + end + + if client.name == "sumneko_lua" then + client.server_capabilities.documentFormattingProvider = false + end + + lsp_keymaps(bufnr) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) +end + +return M diff --git a/nvim/.config/nvim/lua/user/lsp/handlers.lua.orig b/nvim/.config/nvim/lua/user/lsp/handlers.lua.orig new file mode 100644 index 0000000..a92d77b --- /dev/null +++ b/nvim/.config/nvim/lua/user/lsp/handlers.lua.orig @@ -0,0 +1,113 @@ +local M = {} + +local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_cmp_ok then + return +end + +M.capabilities = vim.lsp.protocol.make_client_capabilities() +M.capabilities.textDocument.completion.completionItem.snippetSupport = true +M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities) + +M.setup = function() + local signs = { + + { name = "DiagnosticSignError", text = "" }, + { name = "DiagnosticSignWarn", text = "" }, + { name = "DiagnosticSignHint", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + virtual_text = false, -- disable virtual text + signs = { + active = signs, -- show signs + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + local keymap = vim.api.nvim_buf_set_keymap + keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) + keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) + keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) + keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) + keymap(bufnr, "n", "lf", "lua vim.lsp.buf.format{ async = true }", opts) + keymap(bufnr, "n", "li", "LspInfo", opts) + keymap(bufnr, "n", "lI", "LspInstallInfo", opts) + keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) + keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) + keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) + keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) + keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) + keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.server_capabilities.documentFormattingProvider = false + end + + if client.name == "sumneko_lua" then + client.server_capabilities.documentFormattingProvider = false + end + +<<<<<<< HEAD + lsp_keymaps(bufnr) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) +||||||| parent of d36bf7c (rust IDE using rust tools.nvim) + lsp_keymaps(bufnr) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) +======= + if client.name == "rust_analyzer" then + -- print("turned on codelens") + -- vim.lsp.codelens.refresh() + end + + lsp_keymaps(bufnr) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) + -- vim.lsp.codelens.refresh() +>>>>>>> d36bf7c (rust IDE using rust tools.nvim) +end + +return M diff --git a/nvim/.config/nvim/lua/user/lsp/init.lua b/nvim/.config/nvim/lua/user/lsp/init.lua new file mode 100644 index 0000000..c8eef0f --- /dev/null +++ b/nvim/.config/nvim/lua/user/lsp/init.lua @@ -0,0 +1,8 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + +require "user.lsp.mason" +require("user.lsp.handlers").setup() +require "user.lsp.null-ls" diff --git a/nvim/.config/nvim/lua/user/lsp/mason.lua b/nvim/.config/nvim/lua/user/lsp/mason.lua new file mode 100644 index 0000000..af3a665 --- /dev/null +++ b/nvim/.config/nvim/lua/user/lsp/mason.lua @@ -0,0 +1,52 @@ +local servers = { + "sumneko_lua", + "cssls", + "html", + "tsserver", + "pyright", + "bashls", + "jsonls", + "yamlls", +} + +local settings = { + ui = { + border = "none", + icons = { + package_installed = "◍", + package_pending = "◍", + package_uninstalled = "◍", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, +} + +require("mason").setup(settings) +require("mason-lspconfig").setup({ + ensure_installed = servers, + automatic_installation = true, +}) + +local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status_ok then + return +end + +local opts = {} + +for _, server in pairs(servers) do + opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + + server = vim.split(server, "@")[1] + + local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server) + if require_ok then + opts = vim.tbl_deep_extend("force", conf_opts, opts) + end + + lspconfig[server].setup(opts) +end diff --git a/nvim/.config/nvim/lua/user/lsp/null-ls.lua b/nvim/.config/nvim/lua/user/lsp/null-ls.lua new file mode 100644 index 0000000..3f24587 --- /dev/null +++ b/nvim/.config/nvim/lua/user/lsp/null-ls.lua @@ -0,0 +1,24 @@ +local null_ls_status_ok, null_ls = pcall(require, "null-ls") +if not null_ls_status_ok then + return +end + +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting +local formatting = null_ls.builtins.formatting +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics +local diagnostics = null_ls.builtins.diagnostics + +-- https://github.com/prettier-solidity/prettier-plugin-solidity +null_ls.setup { + debug = false, + sources = { + formatting.prettier.with { + extra_filetypes = { "toml" }, + extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" }, + }, + formatting.black.with { extra_args = { "--fast" } }, + formatting.stylua, + formatting.google_java_format, + diagnostics.flake8, + }, +} diff --git a/nvim/.config/nvim/lua/user/lsp/settings/pyright.lua b/nvim/.config/nvim/lua/user/lsp/settings/pyright.lua new file mode 100644 index 0000000..c2a518d --- /dev/null +++ b/nvim/.config/nvim/lua/user/lsp/settings/pyright.lua @@ -0,0 +1,9 @@ +return { + settings = { + python = { + analysis = { + typeCheckingMode = "off", + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua b/nvim/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..1154de2 --- /dev/null +++ b/nvim/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua @@ -0,0 +1,18 @@ +return { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.stdpath "config" .. "/lua"] = true, + }, + }, + telemetry = { + enable = false, + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/user/lualine.lua b/nvim/.config/nvim/lua/user/lualine.lua new file mode 100644 index 0000000..dbb3398 --- /dev/null +++ b/nvim/.config/nvim/lua/user/lualine.lua @@ -0,0 +1,58 @@ +local status_ok, lualine = pcall(require, "lualine") +if not status_ok then + return +end + +local hide_in_width = function() + return vim.fn.winwidth(0) > 80 +end + +local diagnostics = { + "diagnostics", + sources = { "nvim_diagnostic" }, + sections = { "error", "warn" }, + symbols = { error = " ", warn = " " }, + colored = false, + always_visible = true, +} + +local diff = { + "diff", + colored = false, + symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols + cond = hide_in_width, +} + +local filetype = { + "filetype", + icons_enabled = false, +} + +local location = { + "location", + padding = 0, +} + +local spaces = function() + return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") +end + +lualine.setup { + options = { + globalstatus = true, + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { "alpha", "dashboard" }, + always_divide_middle = true, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = {"branch"}, + lualine_c = { diagnostics }, + lualine_x = { diff, spaces, "encoding", filetype }, + lualine_y = { location }, + lualine_z = { "progress" }, + }, +} diff --git a/nvim/.config/nvim/lua/user/nvim-tree.lua b/nvim/.config/nvim/lua/user/nvim-tree.lua new file mode 100644 index 0000000..1a41989 --- /dev/null +++ b/nvim/.config/nvim/lua/user/nvim-tree.lua @@ -0,0 +1,67 @@ +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback + +nvim_tree.setup { + update_focused_file = { + enable = true, + update_cwd = true, + }, + renderer = { + root_folder_modifier = ":t", + icons = { + glyphs = { + default = "", + symlink = "", + folder = { + arrow_open = "", + arrow_closed = "", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + untracked = "U", + deleted = "", + ignored = "◌", + }, + }, + }, + }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + view = { + width = 30, + side = "left", + mappings = { + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/user/options.lua b/nvim/.config/nvim/lua/user/options.lua new file mode 100644 index 0000000..a8c5345 --- /dev/null +++ b/nvim/.config/nvim/lua/user/options.lua @@ -0,0 +1,42 @@ +vim.opt.backup = false -- creates a backup file +vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard +vim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messages +vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp +vim.opt.conceallevel = 0 -- so that `` is visible in markdown files +vim.opt.fileencoding = "utf-8" -- the encoding written to a file +vim.opt.hlsearch = true -- highlight all matches on previous search pattern +vim.opt.ignorecase = true -- ignore case in search patterns +vim.opt.mouse = "a" -- allow the mouse to be used in neovim +vim.opt.pumheight = 10 -- pop up menu height +vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore +vim.opt.showtabline = 0 -- always show tabs +vim.opt.smartcase = true -- smart case +vim.opt.smartindent = true -- make indenting smarter again +vim.opt.splitbelow = true -- force all horizontal splits to go below current window +vim.opt.splitright = true -- force all vertical splits to go to the right of current window +vim.opt.swapfile = false -- creates a swapfile +vim.opt.termguicolors = true -- set term gui colors (most terminals support this) +vim.opt.timeoutlen = 1000 -- time to wait for a mapped sequence to complete (in milliseconds) +vim.opt.undofile = true -- enable persistent undo +vim.opt.updatetime = 300 -- faster completion (4000ms default) +vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited +vim.opt.expandtab = true -- convert tabs to spaces +vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation +vim.opt.tabstop = 2 -- insert 2 spaces for a tab +vim.opt.cursorline = true -- highlight the current line +vim.opt.number = true -- set numbered lines +vim.opt.laststatus = 3 -- only the last window will always have a status line +vim.opt.showcmd = false -- hide (partial) command in the last line of the screen (for performance) +vim.opt.ruler = false -- hide the line and column number of the cursor position +vim.opt.numberwidth = 4 -- minimal number of columns to use for the line number {default 4} +vim.opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time +vim.opt.wrap = false -- display lines as one long line +vim.opt.scrolloff = 8 -- minimal number of screen lines to keep above and below the cursor +vim.opt.sidescrolloff = 8 -- minimal number of screen columns to keep to the left and right of the cursor if wrap is `false` +vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications +vim.opt.fillchars.eob=" " -- show empty lines at the end of a buffer as ` ` {default `~`} +vim.opt.shortmess:append "c" -- hide all the completion messages, e.g. "-- XXX completion (YYY)", "match 1 of 2", "The only match", "Pattern not found" +vim.opt.whichwrap:append("<,>,[,],h,l") -- keys allowed to move to the previous/next line when the beginning/end of line is reached +vim.opt.iskeyword:append("-") -- treats words with `-` as single words +vim.opt.formatoptions:remove({ "c", "r", "o" }) -- This is a sequence of letters which describes how automatic formatting is to be done +vim.opt.linebreak = true diff --git a/nvim/.config/nvim/lua/user/plugins.lua b/nvim/.config/nvim/lua/user/plugins.lua new file mode 100644 index 0000000..0120721 --- /dev/null +++ b/nvim/.config/nvim/lua/user/plugins.lua @@ -0,0 +1,111 @@ +local fn = vim.fn + +-- Automatically install packer +local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system { + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + } + print "Installing packer close and reopen Neovim..." + vim.cmd [[packadd packer.nvim]] +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd [[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]] + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, + git = { + clone_timeout = 300, -- Timeout, in seconds, for git clones + }, +} + +-- Install your plugins here +return packer.startup(function(use) + -- My plugins here + use { "wbthomason/packer.nvim", commit = "6afb67460283f0e990d35d229fd38fdc04063e0a" } -- Have packer manage itself + use { "nvim-lua/plenary.nvim", commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7" } -- Useful lua functions used by lots of plugins + use { "windwp/nvim-autopairs", commit = "4fc96c8f3df89b6d23e5092d31c866c53a346347" } -- Autopairs, integrates with both cmp and treesitter + use { "numToStr/Comment.nvim", commit = "97a188a98b5a3a6f9b1b850799ac078faa17ab67" } + use { "JoosepAlviste/nvim-ts-context-commentstring", commit = "32d9627123321db65a4f158b72b757bcaef1a3f4" } + use { "kyazdani42/nvim-web-devicons", commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352" } + use { "kyazdani42/nvim-tree.lua", commit = "7282f7de8aedf861fe0162a559fc2b214383c51c" } + use { "akinsho/bufferline.nvim", commit = "83bf4dc7bff642e145c8b4547aa596803a8b4dc4" } + use { "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" } + use { "nvim-lualine/lualine.nvim", commit = "a52f078026b27694d2290e34efa61a6e4a690621" } + use { "akinsho/toggleterm.nvim", commit = "2a787c426ef00cb3488c11b14f5dcf892bbd0bda" } + use { "ahmedkhalf/project.nvim", commit = "685bc8e3890d2feb07ccf919522c97f7d33b94e4" } + use { "lewis6991/impatient.nvim", commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6" } + use { "lukas-reineke/indent-blankline.nvim", commit = "db7cbcb40cc00fc5d6074d7569fb37197705e7f6" } + use { "goolord/alpha-nvim", commit = "0bb6fc0646bcd1cdb4639737a1cee8d6e08bcc31" } + + -- Colorschemes + use { "folke/tokyonight.nvim", commit = "66bfc2e8f754869c7b651f3f47a2ee56ae557764" } + use { "lunarvim/darkplus.nvim", commit = "13ef9daad28d3cf6c5e793acfc16ddbf456e1c83" } + use { "ellisonleao/gruvbox.nvim", commit = "9ec1d44d8485e9d4f615bdc41e164169564e9f89" } + + -- cmp plugins + use { "hrsh7th/nvim-cmp", commit = "b0dff0ec4f2748626aae13f011d1a47071fe9abc" } -- The completion plugin + use { "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" } -- buffer completions + use { "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1" } -- path completions + use { "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" } -- snippet completions + use { "hrsh7th/cmp-nvim-lsp", commit = "affe808a5c56b71630f17aa7c38e15c59fd648a8" } + use { "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" } + + -- snippets + use { "L3MON4D3/LuaSnip", commit = "8f8d493e7836f2697df878ef9c128337cbf2bb84" } --snippet engine + use { "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" } -- a bunch of snippets to use + + -- LSP + -- use { "williamboman/nvim-lsp-installer", commit = "e9f13d7acaa60aff91c58b923002228668c8c9e6" } -- simple to use language server installer + use { "neovim/nvim-lspconfig", commit = "f11fdff7e8b5b415e5ef1837bdcdd37ea6764dda" } -- enable LSP + use { "williamboman/mason.nvim", commit = "bfc5997e52fe9e20642704da050c415ea1d4775f"} + use { "williamboman/mason-lspconfig.nvim", commit = "0eb7cfefbd3a87308c1875c05c3f3abac22d367c" } + use { "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" } -- for formatters and linters + use { "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" } + use {"simrat39/rust-tools.nvim", commit = "11dcd674781ba68a951ab4c7b740553cae8fe671"} + + -- Telescope + use { "nvim-telescope/telescope.nvim", commit = "76ea9a898d3307244dce3573392dcf2cc38f340f" } + + -- Treesitter + use { + "nvim-treesitter/nvim-treesitter", + commit = "8e763332b7bf7b3a426fd8707b7f5aa85823a5ac", + } + + -- Git + use { "lewis6991/gitsigns.nvim", commit = "f98c85e7c3d65a51f45863a34feb4849c82f240f" } + + -- DAP + use { "mfussenegger/nvim-dap", commit = "6b12294a57001d994022df8acbe2ef7327d30587" } + use { "rcarriga/nvim-dap-ui", commit = "1cd4764221c91686dcf4d6b62d7a7b2d112e0b13" } + use { "ravenxrz/DAPInstall.nvim", commit = "8798b4c36d33723e7bba6ed6e2c202f84bb300de" } + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/nvim/.config/nvim/lua/user/plugins.lua.orig b/nvim/.config/nvim/lua/user/plugins.lua.orig new file mode 100644 index 0000000..8252eb5 --- /dev/null +++ b/nvim/.config/nvim/lua/user/plugins.lua.orig @@ -0,0 +1,122 @@ +local fn = vim.fn + +-- Automatically install packer +local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system { + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + } + print "Installing packer close and reopen Neovim..." + vim.cmd [[packadd packer.nvim]] +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd [[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]] + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, + git = { + clone_timeout = 300, -- Timeout, in seconds, for git clones + }, +} + +-- Install your plugins here +return packer.startup(function(use) + -- My plugins here + use { "wbthomason/packer.nvim", commit = "6afb67460283f0e990d35d229fd38fdc04063e0a" } -- Have packer manage itself + use { "nvim-lua/plenary.nvim", commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7" } -- Useful lua functions used by lots of plugins + use { "windwp/nvim-autopairs", commit = "4fc96c8f3df89b6d23e5092d31c866c53a346347" } -- Autopairs, integrates with both cmp and treesitter + use { "numToStr/Comment.nvim", commit = "97a188a98b5a3a6f9b1b850799ac078faa17ab67" } + use { "JoosepAlviste/nvim-ts-context-commentstring", commit = "32d9627123321db65a4f158b72b757bcaef1a3f4" } + use { "kyazdani42/nvim-web-devicons", commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352" } + use { "kyazdani42/nvim-tree.lua", commit = "7282f7de8aedf861fe0162a559fc2b214383c51c" } + use { "akinsho/bufferline.nvim", commit = "83bf4dc7bff642e145c8b4547aa596803a8b4dc4" } + use { "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" } + use { "nvim-lualine/lualine.nvim", commit = "a52f078026b27694d2290e34efa61a6e4a690621" } + use { "akinsho/toggleterm.nvim", commit = "2a787c426ef00cb3488c11b14f5dcf892bbd0bda" } + use { "ahmedkhalf/project.nvim", commit = "628de7e433dd503e782831fe150bb750e56e55d6" } + use { "lewis6991/impatient.nvim", commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6" } + use { "lukas-reineke/indent-blankline.nvim", commit = "db7cbcb40cc00fc5d6074d7569fb37197705e7f6" } + use { "goolord/alpha-nvim", commit = "0bb6fc0646bcd1cdb4639737a1cee8d6e08bcc31" } + + -- Colorschemes + use { "folke/tokyonight.nvim", commit = "66bfc2e8f754869c7b651f3f47a2ee56ae557764" } + use { "lunarvim/darkplus.nvim", commit = "13ef9daad28d3cf6c5e793acfc16ddbf456e1c83" } + + -- cmp plugins + use { "hrsh7th/nvim-cmp", commit = "b0dff0ec4f2748626aae13f011d1a47071fe9abc" } -- The completion plugin + use { "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" } -- buffer completions + use { "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1" } -- path completions + use { "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" } -- snippet completions + use { "hrsh7th/cmp-nvim-lsp", commit = "affe808a5c56b71630f17aa7c38e15c59fd648a8" } + use { "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21" } + + -- snippets + use { "L3MON4D3/LuaSnip", commit = "8f8d493e7836f2697df878ef9c128337cbf2bb84" } --snippet engine + use { "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1" } -- a bunch of snippets to use + + -- LSP +<<<<<<< HEAD + -- use { "williamboman/nvim-lsp-installer", commit = "e9f13d7acaa60aff91c58b923002228668c8c9e6" } -- simple to use language server installer + use { "neovim/nvim-lspconfig", commit = "f11fdff7e8b5b415e5ef1837bdcdd37ea6764dda" } -- enable LSP + use { "williamboman/mason.nvim", commit = "bfc5997e52fe9e20642704da050c415ea1d4775f"} + use { "williamboman/mason-lspconfig.nvim", commit = "0eb7cfefbd3a87308c1875c05c3f3abac22d367c" } + use { "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" } -- for formatters and linters + use { "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" } +||||||| parent of d36bf7c (rust IDE using rust tools.nvim) + use { "neovim/nvim-lspconfig", commit = "148c99bd09b44cf3605151a06869f6b4d4c24455" } -- enable LSP + use { "williamboman/nvim-lsp-installer", commit = "e9f13d7acaa60aff91c58b923002228668c8c9e6" } -- simple to use language server installer + use { "jose-elias-alvarez/null-ls.nvim", commit = "ff40739e5be6581899b43385997e39eecdbf9465" } -- for formatters and linters + use { "RRethy/vim-illuminate", commit = "c82e6d04f27a41d7fdcad9be0bce5bb59fcb78e5" } +======= + use { "neovim/nvim-lspconfig", commit = "148c99bd09b44cf3605151a06869f6b4d4c24455" } -- enable LSP + use { "williamboman/nvim-lsp-installer", commit = "e9f13d7acaa60aff91c58b923002228668c8c9e6" } -- simple to use language server installer + use { "jose-elias-alvarez/null-ls.nvim", commit = "ff40739e5be6581899b43385997e39eecdbf9465" } -- for formatters and linters + use { "RRethy/vim-illuminate", commit = "c82e6d04f27a41d7fdcad9be0bce5bb59fcb78e5" } + use {"simrat39/rust-tools.nvim", commit = "11dcd674781ba68a951ab4c7b740553cae8fe671"} +>>>>>>> d36bf7c (rust IDE using rust tools.nvim) + + -- Telescope + use { "nvim-telescope/telescope.nvim", commit = "76ea9a898d3307244dce3573392dcf2cc38f340f" } + + -- Treesitter + use { + "nvim-treesitter/nvim-treesitter", + commit = "8e763332b7bf7b3a426fd8707b7f5aa85823a5ac", + } + + -- Git + use { "lewis6991/gitsigns.nvim", commit = "f98c85e7c3d65a51f45863a34feb4849c82f240f" } + + -- DAP + use { "mfussenegger/nvim-dap", commit = "6b12294a57001d994022df8acbe2ef7327d30587" } + use { "rcarriga/nvim-dap-ui", commit = "1cd4764221c91686dcf4d6b62d7a7b2d112e0b13" } + use { "ravenxrz/DAPInstall.nvim", commit = "8798b4c36d33723e7bba6ed6e2c202f84bb300de" } + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/nvim/.config/nvim/lua/user/project.lua b/nvim/.config/nvim/lua/user/project.lua new file mode 100644 index 0000000..fb8e591 --- /dev/null +++ b/nvim/.config/nvim/lua/user/project.lua @@ -0,0 +1,19 @@ +local status_ok, project = pcall(require, "project_nvim") +if not status_ok then + return +end +project.setup({ + + -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project + detection_methods = { "pattern" }, + + -- patterns used to detect root dir, when **"pattern"** is in detection_methods + patterns = { ".git", "Makefile", "package.json" }, +}) + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +telescope.load_extension('projects') diff --git a/nvim/.config/nvim/lua/user/telescope.lua b/nvim/.config/nvim/lua/user/telescope.lua new file mode 100644 index 0000000..c269db9 --- /dev/null +++ b/nvim/.config/nvim/lua/user/telescope.lua @@ -0,0 +1,45 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +local actions = require "telescope.actions" + +local telescopeConfig = require("telescope.config") + +-- Clone the default Telescope configuration +local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) } + +-- I want to search in hidden/dot files. +table.insert(vimgrep_arguments, "--hidden") +-- I don't want to search in the `.git` directory. +table.insert(vimgrep_arguments, "--glob") +table.insert(vimgrep_arguments, "!**/.git/*") + +telescope.setup { + defaults = { + + prompt_prefix = " ", + selection_caret = " ", + path_display = { "smart" }, + file_ignore_patterns = { ".git/", "node_modules" }, + + vimgrep_arguments = vimgrep_arguments, + + pickers = { + find_files = { + -- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d. + find_command = { "fd", "--type", "f", "--strip-cwd-prefix" }, + }, + }, + + mappings = { + i = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/user/toggleterm.lua b/nvim/.config/nvim/lua/user/toggleterm.lua new file mode 100644 index 0000000..c6af4d5 --- /dev/null +++ b/nvim/.config/nvim/lua/user/toggleterm.lua @@ -0,0 +1,40 @@ +local status_ok, toggleterm = pcall(require, "toggleterm") +if not status_ok then + return +end + +toggleterm.setup({ + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + }, +}) + +function _G.set_terminal_keymaps() + local opts = {noremap = true} + -- vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +local Terminal = require("toggleterm.terminal").Terminal +local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) + +function _LAZYGIT_TOGGLE() + lazygit:toggle() +end + diff --git a/nvim/.config/nvim/lua/user/treesitter.lua b/nvim/.config/nvim/lua/user/treesitter.lua new file mode 100644 index 0000000..e9e31df --- /dev/null +++ b/nvim/.config/nvim/lua/user/treesitter.lua @@ -0,0 +1,31 @@ +local status_ok, treesitter = pcall(require, "nvim-treesitter") +if not status_ok then + return +end + +local status_ok, configs = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +configs.setup({ + ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python" }, -- put the language you want in this array + -- ensure_installed = "all", -- one of "all" or a list of languages + ignore_install = { "" }, -- List of parsers to ignore installing + sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) + + highlight = { + enable = true, -- false will disable the whole extension + disable = { "css" }, -- list of language that will be disabled + }, + autopairs = { + enable = true, + }, + indent = { enable = true, disable = { "python", "css" } }, + + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + +}) diff --git a/nvim/.config/nvim/plugin/packer_compiled.lua b/nvim/.config/nvim/plugin/packer_compiled.lua new file mode 100644 index 0000000..dcbdee7 --- /dev/null +++ b/nvim/.config/nvim/plugin/packer_compiled.lua @@ -0,0 +1,284 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +local time +local profile_info +local should_profile = false +if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end +else + time = function(chunk, start) end +end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end + + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/Users/dg/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/dg/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/dg/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/dg/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/Users/dg/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["Comment.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/Comment.nvim", + url = "https://github.com/numToStr/Comment.nvim" + }, + ["DAPInstall.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/DAPInstall.nvim", + url = "https://github.com/ravenxrz/DAPInstall.nvim" + }, + LuaSnip = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["alpha-nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/alpha-nvim", + url = "https://github.com/goolord/alpha-nvim" + }, + ["bufferline.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/bufferline.nvim", + url = "https://github.com/akinsho/bufferline.nvim" + }, + ["cmp-buffer"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-nvim-lua"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + ["darkplus.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/darkplus.nvim", + url = "https://github.com/lunarvim/darkplus.nvim" + }, + ["friendly-snippets"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, + ["gitsigns.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", + url = "https://github.com/lewis6991/gitsigns.nvim" + }, + ["gruvbox.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/gruvbox.nvim", + url = "https://github.com/ellisonleao/gruvbox.nvim" + }, + ["impatient.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/impatient.nvim", + url = "https://github.com/lewis6991/impatient.nvim" + }, + ["indent-blankline.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", + url = "https://github.com/lukas-reineke/indent-blankline.nvim" + }, + ["lualine.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/lualine.nvim", + url = "https://github.com/nvim-lualine/lualine.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + ["null-ls.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, + ["nvim-autopairs"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-autopairs", + url = "https://github.com/windwp/nvim-autopairs" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-dap"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-dap", + url = "https://github.com/mfussenegger/nvim-dap" + }, + ["nvim-dap-ui"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-dap-ui", + url = "https://github.com/rcarriga/nvim-dap-ui" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-tree.lua"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + url = "https://github.com/kyazdani42/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-ts-context-commentstring"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-ts-context-commentstring", + url = "https://github.com/JoosepAlviste/nvim-ts-context-commentstring" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/kyazdani42/nvim-web-devicons" + }, + ["packer.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["project.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/project.nvim", + url = "https://github.com/ahmedkhalf/project.nvim" + }, + ["rust-tools.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/rust-tools.nvim", + url = "https://github.com/simrat39/rust-tools.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["toggleterm.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/toggleterm.nvim", + url = "https://github.com/akinsho/toggleterm.nvim" + }, + ["tokyonight.nvim"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/tokyonight.nvim", + url = "https://github.com/folke/tokyonight.nvim" + }, + ["vim-bbye"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/vim-bbye", + url = "https://github.com/moll/vim-bbye" + }, + ["vim-illuminate"] = { + loaded = true, + path = "/Users/dg/.local/share/nvim/site/pack/packer/start/vim-illuminate", + url = "https://github.com/RRethy/vim-illuminate" + } +} + +time([[Defining packer_plugins]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = false + +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end diff --git a/nvim/.config/nvim/scripts/spacetab.vim b/nvim/.config/nvim/scripts/spacetab.vim deleted file mode 100644 index 5016683..0000000 --- a/nvim/.config/nvim/scripts/spacetab.vim +++ /dev/null @@ -1,5 +0,0 @@ -" Because sometimes, spaces are mandated -set shiftwidth=4 -set softtabstop=4 -set tabstop=4 -set expandtab