Compare commits

...

7 Commits

Author SHA1 Message Date
Ali Can Zeybek
b76ddb4d9b tests and terminal 2026-02-08 15:02:24 +03:00
Ali Can Zeybek
412040b46d debug and problems 2026-02-08 12:54:03 +03:00
Ali Can Zeybek
5d208f102a add some stuff 2026-01-26 22:08:10 +03:00
1005194679 update 2026-01-16 22:15:49 +03:00
Ali Can Zeybek
29938c53db update 2023-08-14 14:29:03 +03:00
Ali Can Zeybek
6d8f231fd3 update 2023-08-09 16:27:14 +03:00
Ali Can Zeybek
8a6816da0e removed compiled plugin dir 2022-12-19 19:53:33 +03:00
45 changed files with 1311 additions and 1551 deletions

164
AGENTS.md Normal file
View File

@@ -0,0 +1,164 @@
# AGENTS.md
This document is the operating guide for coding agents working in this Neovim
configuration repository.
## Repository Snapshot
- Project type: personal Neovim config (Lua)
- Entry point: `init.lua` -> `lua/core/*` -> `lua/plugins/*`
- Plugin manager: `lazy.nvim`
- No dedicated CI, test suite, formatter config, or lint config is committed
- Primary language: Lua (Neovim runtime APIs)
## Directory Layout
- `init.lua`: bootstrap into core config
- `lua/core/options.lua`: editor options and globals
- `lua/core/keymaps.lua`: global and command keymaps
- `lua/core/lazy.lua`: lazy.nvim bootstrap and setup
- `lua/plugins/init.lua`: plugin spec list
- `lua/plugins/config/*.lua`: per-plugin config modules
- `lua/utils/*.lua`: utility helpers (for example `reload.lua`)
## Build / Lint / Test Commands
There is no Makefile/package manager script layer, so use direct commands.
### Environment checks
- Verify Neovim can start this config:
- `nvim --headless -u /home/alican/.config/nvim/init.lua +qa`
- Verify plugin bootstrap and lockfile resolution:
- `nvim --headless -u /home/alican/.config/nvim/init.lua '+Lazy! sync' +qa`
- Optional runtime health checks:
- `nvim --headless -u /home/alican/.config/nvim/init.lua '+checkhealth' +qa`
### Formatting
- Preferred formatter for Lua: `stylua`
- Format whole repo:
- `stylua /home/alican/.config/nvim`
- Format a single file:
- `stylua /home/alican/.config/nvim/lua/plugins/init.lua`
If `stylua` is not installed, do not mass-reformat; preserve existing style in
touched regions only.
### Linting
- No lint config is committed (`.luacheckrc` not found).
- If `luacheck` is available, run ad hoc:
- `luacheck /home/alican/.config/nvim/lua`
- Treat lint as advisory unless the repository later adds pinned lint rules.
### Testing
- No test framework is currently configured in-repo.
- Use headless startup as the minimum smoke test:
- `nvim --headless -u /home/alican/.config/nvim/init.lua +qa`
### Running a single test (important)
There are no existing unit/integration test files, so there is no real
single-test command today.
If you add Plenary-based tests, use this pattern for a single test file:
- `nvim --headless -u /home/alican/.config/nvim/init.lua -c "PlenaryBustedFile tests/<name>_spec.lua" -c qa`
If you add a plain Lua test runner later, document exact single-test invocations
here and keep this section updated.
## Code Style Guidelines
Follow local conventions observed in current files first, then these rules.
### Imports and module structure
- Use `require("...")` with explicit module paths.
- Keep imports at top of file unless lazy-loading is intentional.
- Prefer locals for required modules (example: `local cmp = require("cmp")`).
- Return module tables (`local M = {}; ...; return M`) for utility modules.
- Plugin config modules should avoid side effects outside setup behavior.
### Formatting and layout
- Preserve existing indentation style per file (repo currently mixes tabs/spaces).
- Keep lines reasonably short (existing config uses `colorcolumn = "80"`).
- Use trailing commas in multiline Lua tables.
- Keep one logical statement per line.
- Group related options/settings in contiguous blocks.
- Avoid large unrelated reformatting in feature/fix commits.
### Types and annotations
- Lua is dynamically typed here; no strict type checker is configured.
- Keep useful EmmyLua annotations when present (for example `---@type ...`).
- Add annotations only when they improve editor/LSP inference.
- Do not add noisy type comments for obvious locals.
### Naming conventions
- Module/file names: lowercase, path-based (`core.options`, `plugins.config.lsp`).
- Local variables: `snake_case`.
- Exported module tables: `M`.
- User commands: `PascalCase` where already used (`ReloadConfig`).
- Avoid introducing new global functions/variables.
- Exception: if global is required by Vim command callbacks, prefix carefully and
document intent.
### Neovim API usage
- Prefer modern APIs:
- `vim.keymap.set` over `vim.api.nvim_set_keymap`
- `vim.api.nvim_create_user_command` for user commands
- Use buffer-local mappings/options when behavior is buffer-scoped.
- Keep plugin setup isolated in `lua/plugins/config/<plugin>.lua` when practical.
- Keep core bootstrap files (`core/*`) minimal and composable.
### Error handling and resilience
- Fail softly for optional dependencies when reasonable (`pcall(require, ...)`).
- Avoid crashing startup for non-critical plugin behavior.
- Use `vim.notify(..., vim.log.levels.<LEVEL>)` for actionable runtime feedback.
- For external commands in Lua, check return status if failure is meaningful.
### Plugin and dependency changes
- Add/modify plugin specs only in `lua/plugins/init.lua` unless refactoring.
- Keep plugin options in dedicated config modules when they grow beyond trivial.
- For plugins with build hooks (example: markdown preview), do not assume Node/npm
is available in all environments; mention prerequisites in PR notes.
- Preserve lockfile intent (`lazy-lock.json`) when updating plugin versions.
### Commit hygiene for agents
- Make focused changes with minimal scope.
- Do not fix unrelated style issues opportunistically.
- Include validation notes in your final response (what you ran, what you could
not run).
- If commands are unavailable locally, state that clearly and provide exact
follow-up commands.
## Cursor / Copilot Rules
Checked paths:
- `.cursorrules`
- `.cursor/rules/`
- `.github/copilot-instructions.md`
Current status: no Cursor or Copilot instruction files were found in this
repository.
If these files are added later, agents must treat them as higher-priority
repository policy and this document should be updated to summarize them.
## Agent Workflow Checklist
- Read nearby files before editing; match local patterns.
- Keep edits minimal and reversible.
- Run at least one headless Neovim smoke check after non-trivial changes.
- For plugin changes, run `'+Lazy! sync'` headless when possible.
- Update this file when tooling, test framework, or style policy changes.

View File

View File

@@ -1,12 +1,3 @@
require "user.options"
require "user.keymaps"
require "user.plugins"
require "user.colorscheme"
require "user.cmp"
require "user.lsp"
require "user.telescope"
require "user.treesitter"
require "user.gitsigns"
require "user.nvim-tree"
require "user.toggleterm"
require "user.lualine"
-- Load core config
require("core")

View File

@@ -1,274 +0,0 @@
syntax on
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set number
set relativenumber
set smartcase
set ignorecase
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
set incsearch
set hidden
set colorcolumn=80
set scrolloff=12
set signcolumn=yes
set clipboard=unnamedplus
set nocompatible
filetype plugin on
highlight ColorColumn ctermbg=0 guibg=lightgrey
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'preservim/nerdtree'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
Plug 'vim-utils/vim-man'
Plug 'tpope/vim-fugitive'
Plug 'kien/ctrlp.vim'
Plug 'mbbill/undotree'
Plug 'sainnhe/gruvbox-material'
Plug 'xuhdev/vim-latex-live-preview'
" Plug 'lervag/vimtex'
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'preservim/vim-pencil'
Plug 'justinmk/vim-sneak'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()
colorscheme gruvbox-material
set background=dark
"highlight Normal ctermbg=None
if executable('rg')
let g:rg_derive_root='true'
endif
let g:ctrlp_user_command = ['.git/','git --git-dir=%s/.git ls-files -oc --exclude-standard']
let mapleader = " "
let g:netrw_browse_split=2
let g:netrw_banner = 0
let g:ctrlp_use_caching = 0
let g:getrw_winsize = 25
let g:gruvbox_transparent_bg = 1
let g:sneak#label = 1
let g:airline_theme='gruvbox_material'
let g:vim_markdown_folding_disabled = 1
let g:vimtex_view_method = 'zathura'
let g:livepreview_previewer = 'zathura'
let g:vimtex_compiler_method = 'latexrun'
let NERDTreeShowHidden=1
"coc stuff
set encoding=UTF-8
set cmdheight=2
set updatetime=300
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("nvim-0.5.0") || has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
"coc stuff end
nnoremap <leader>h : wincmd h<CR>
nnoremap <leader>j : wincmd j<CR>
nnoremap <leader>k : wincmd k<CR>
nnoremap <leader>l : wincmd l<CR>
nnoremap <leader>u : UndotreeShow<CR>
nnoremap <leader>pv : wincmd v<bar> : Ex <bar> : vertical resize 30<CR>
nnoremap <Leader>ps : Rg<space>
nnoremap <silent> <Leader>+ : vertical resize +5<CR>
nnoremap <silent> <Leader>- : vertical resize -5<CR>
"nnoremap <silent> <Leader>gd : YcmCompleter GoTo<CR>
"nnoremap <silent> <Leader>gf : YcmCompleter FixIt<CR>
nmap <C-n> :NERDTreeToggle<CR>
let g:NERDTreeGitStatusWithFlags = 1
let g:NERDTreeIgnore = ['^node_modules$']
"autocmd VimEnter * NERDTree
nnoremap <leader>ff <cmd>Telescope find_files hidden=true<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
"fun! TrimWhitespace()
" let l:save = winsaveview()
" keeppatterns %s/\s\+$//e
" call winrestview(l:save)
"endfun
" augroup THE_PRIMEAGEN
" autocmd!
" " autocmd BufWritePre * :call TrimWhitespace()
" autocmd BufWritePost *.cpp !astyle %
" autocmd BufWritePost *.cpp edit
" autocmd BufWritePost *.cpp redraw!
" augroup END
"
" =================================================
" pencil
" =================================================
"
let g:pencil#wrapModeDefault = 'soft'
augroup pencil
autocmd!
autocmd FileType markdown,mkd call pencil#init()
autocmd FileType text call pencil#init()
augroup END

3
lua/core/init.lua Normal file
View File

@@ -0,0 +1,3 @@
require("core.options")
require("core.keymaps")
require("core.lazy")

289
lua/core/keymaps.lua Normal file
View File

@@ -0,0 +1,289 @@
-- Use native Neovim Lua keymap API
local keymap = vim.keymap
keymap.set("n", "<leader>h", "<C-w>h", { noremap = true, silent = true, desc = "Window left" })
keymap.set("n", "<leader>j", "<C-w>j", { noremap = true, silent = true, desc = "Window down" })
keymap.set("n", "<leader>k", "<C-w>k", { noremap = true, silent = true, desc = "Window up" })
keymap.set("n", "<leader>l", "<C-w>l", { noremap = true, silent = true, desc = "Window right" })
keymap.set("t", "<leader>h", [[<C-\><C-n><C-w>h]], { noremap = true, silent = true, desc = "Window left" })
keymap.set("t", "<leader>j", [[<C-\><C-n><C-w>j]], { noremap = true, silent = true, desc = "Window down" })
keymap.set("t", "<leader>k", [[<C-\><C-n><C-w>k]], { noremap = true, silent = true, desc = "Window up" })
keymap.set("t", "<leader>l", [[<C-\><C-n><C-w>l]], { noremap = true, silent = true, desc = "Window right" })
local reload = require("utils.reload")
vim.api.nvim_create_user_command("ReloadConfig", reload.reload, {})
vim.keymap.set("n", "<leader><leader>r", reload.reload, { noremap = true, silent = true, desc = "Reload config" })
keymap.set("n", "<leader>?", function()
local ok, wk = pcall(require, "which-key")
if not ok then
vim.notify("which-key is not available", vim.log.levels.WARN)
return
end
local ok_show = pcall(wk.show, { keys = "<leader>", mode = "n" })
if not ok_show then
vim.cmd("WhichKey <leader>")
end
end, { noremap = true, silent = true, desc = "Leader keymaps" })
keymap.set("n", "<leader>ff", "<cmd>lua require('telescope.builtin').find_files()<cr>", {noremap = true, silent = true, desc = "Find files"})
keymap.set("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>", {noremap = true, silent = true, desc = "Find text"})
keymap.set("n", "<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>", {noremap = true, silent = true, desc = "Find buffers"})
keymap.set("n", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>", {noremap = true, silent = true, desc = "Find help"})
keymap.set("n", "<leader>xx", "<cmd>Trouble diagnostics toggle<CR>", { noremap = true, silent = true, desc = "Problems toggle" })
keymap.set("n", "<leader>xw", "<cmd>Trouble diagnostics toggle<CR>", { noremap = true, silent = true, desc = "Problems workspace diagnostics" })
keymap.set("n", "<leader>xb", "<cmd>Trouble diagnostics toggle filter.buf=0<CR>", { noremap = true, silent = true, desc = "Problems buffer diagnostics" })
keymap.set("n", "<leader>xq", "<cmd>Trouble qflist toggle<CR>", { noremap = true, silent = true, desc = "Problems quickfix" })
keymap.set("n", "<leader>xl", "<cmd>Trouble loclist toggle<CR>", { noremap = true, silent = true, desc = "Problems location list" })
keymap.set("n", "<leader>xr", "<cmd>Trouble lsp_references toggle<CR>", { noremap = true, silent = true, desc = "Problems references" })
keymap.set("n", "<leader>xs", "<cmd>Trouble symbols toggle focus=false<CR>", { noremap = true, silent = true, desc = "Problems document symbols" })
keymap.set("n", "<leader>xS", "<cmd>Trouble lsp toggle focus=false win.position=right<CR>", { noremap = true, silent = true, desc = "Problems workspace symbols" })
local function with_toggleterm(fn)
local ok, toggleterm = pcall(require, "plugins.config.toggleterm")
if not ok then
pcall(function()
require("lazy").load({ plugins = { "toggleterm.nvim" } })
end)
ok, toggleterm = pcall(require, "plugins.config.toggleterm")
end
if not ok then
vim.notify("toggleterm is not available", vim.log.levels.WARN)
return
end
fn(toggleterm)
end
keymap.set("n", "<leader>mm", function()
with_toggleterm(function(toggleterm)
toggleterm.toggle_shell()
end)
end, { noremap = true, silent = true, desc = "Build terminal" })
keymap.set("t", "<leader>mm", [[<C-\><C-n><cmd>lua require("plugins.config.toggleterm").toggle_shell()<CR>]], { noremap = true, silent = true, desc = "Build terminal" })
keymap.set("n", "<leader>mc", function()
with_toggleterm(function(toggleterm)
toggleterm.rerun_last()
end)
end, { noremap = true, silent = true, desc = "Build rerun last" })
keymap.set("n", "<leader>m1", function()
with_toggleterm(function(toggleterm)
toggleterm.toggle_build_terminal()
end)
end, { noremap = true, silent = true, desc = "Build toggle terminal" })
keymap.set("t", "<leader>m1", [[<C-\><C-n><cmd>lua require("plugins.config.toggleterm").toggle_build_terminal()<CR>]], { noremap = true, silent = true, desc = "Build toggle terminal" })
keymap.set("n", "<leader>m2", function()
with_toggleterm(function(toggleterm)
toggleterm.toggle_test_terminal()
end)
end, { noremap = true, silent = true, desc = "Build test terminal" })
keymap.set("t", "<leader>m2", [[<C-\><C-n><cmd>lua require("plugins.config.toggleterm").toggle_test_terminal()<CR>]], { noremap = true, silent = true, desc = "Build test terminal" })
local function with_neotest(fn)
local ok, neotest = pcall(require, "neotest")
if not ok then
vim.notify("neotest is not available", vim.log.levels.WARN)
return
end
fn(neotest)
end
local function project_root_for_tests()
local current_file = vim.api.nvim_buf_get_name(0)
local start_path = current_file ~= "" and vim.fs.dirname(current_file) or vim.loop.cwd()
local markers = { "CMakePresets.json", "CMakeLists.txt", ".git" }
local found = vim.fs.find(markers, { upward = true, path = start_path })[1]
if found then
return vim.fs.dirname(found)
end
return vim.loop.cwd()
end
keymap.set("n", "<leader>tt", function()
with_neotest(function(neotest)
neotest.run.run()
end)
end, { noremap = true, silent = true, desc = "Tests run nearest" })
keymap.set("n", "<leader>tf", function()
with_neotest(function(neotest)
neotest.run.run(vim.fn.expand("%"))
end)
end, { noremap = true, silent = true, desc = "Tests run file" })
keymap.set("n", "<leader>ta", function()
with_neotest(function(neotest)
neotest.run.run(project_root_for_tests())
end)
end, { noremap = true, silent = true, desc = "Tests run all" })
keymap.set("n", "<leader>tg", function()
with_toggleterm(function(toggleterm)
toggleterm.run_tests()
end)
end, { noremap = true, silent = true, desc = "Tests run via ctest" })
keymap.set("n", "<leader>td", function()
with_neotest(function(neotest)
neotest.run.run({ strategy = "dap" })
end)
end, { noremap = true, silent = true, desc = "Tests debug nearest" })
keymap.set("n", "<leader>to", function()
with_neotest(function(neotest)
neotest.output.open({ enter = true, auto_close = true })
end)
end, { noremap = true, silent = true, desc = "Tests open output" })
keymap.set("n", "<leader>tp", function()
with_neotest(function(neotest)
neotest.output_panel.toggle()
end)
end, { noremap = true, silent = true, desc = "Tests toggle output panel" })
keymap.set("n", "<leader>ts", function()
with_neotest(function(neotest)
neotest.summary.toggle()
end)
end, { noremap = true, silent = true, desc = "Tests toggle summary" })
keymap.set("n", "<leader>tS", function()
with_neotest(function(neotest)
neotest.run.stop()
end)
end, { noremap = true, silent = true, desc = "Tests stop" })
vim.keymap.set("n", "gn", vim.diagnostic.goto_next, { noremap = true, silent = true })
local function with_dap(fn)
local ok, dap = pcall(require, "dap")
if not ok then
vim.notify("nvim-dap is not available", vim.log.levels.WARN)
return
end
fn(dap)
end
local function with_dapui(fn)
local ok, dapui = pcall(require, "dapui")
if not ok then
vim.notify("nvim-dap-ui is not available", vim.log.levels.WARN)
return
end
fn(dapui)
end
keymap.set("n", "<leader>dc", function()
with_dap(function(dap)
dap.continue()
end)
end, { noremap = true, silent = true, desc = "Debug continue" })
keymap.set("n", "<leader>dr", function()
with_dap(function(dap)
dap.restart()
end)
end, { noremap = true, silent = true, desc = "Debug restart" })
keymap.set("n", "<leader>dt", function()
with_dap(function(dap)
dap.terminate()
end)
end, { noremap = true, silent = true, desc = "Debug terminate" })
keymap.set("n", "<leader>dp", function()
with_dap(function(dap)
dap.pause()
end)
end, { noremap = true, silent = true, desc = "Debug pause" })
keymap.set("n", "<leader>do", function()
with_dap(function(dap)
dap.step_over()
end)
end, { noremap = true, silent = true, desc = "Debug step over" })
keymap.set("n", "<leader>di", function()
with_dap(function(dap)
dap.step_into()
end)
end, { noremap = true, silent = true, desc = "Debug step into" })
keymap.set("n", "<leader>dO", function()
with_dap(function(dap)
dap.step_out()
end)
end, { noremap = true, silent = true, desc = "Debug step out" })
keymap.set("n", "<leader>du", function()
with_dap(function(dap)
dap.run_to_cursor()
end)
end, { noremap = true, silent = true, desc = "Debug run to cursor" })
keymap.set("n", "<leader>db", function()
with_dap(function(dap)
dap.toggle_breakpoint()
end)
end, { noremap = true, silent = true, desc = "Debug toggle breakpoint" })
keymap.set("n", "<leader>dB", function()
with_dap(function(dap)
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end)
end, { noremap = true, silent = true, desc = "Debug conditional breakpoint" })
keymap.set("n", "<leader>dl", function()
with_dap(function(dap)
dap.set_breakpoint(nil, nil, vim.fn.input("Log point message: "))
end)
end, { noremap = true, silent = true, desc = "Debug logpoint" })
keymap.set("n", "<leader>dx", function()
with_dap(function(dap)
dap.clear_breakpoints()
end)
end, { noremap = true, silent = true, desc = "Debug clear breakpoints" })
keymap.set("n", "<leader>dd", function()
with_dapui(function(dapui)
dapui.toggle()
end)
end, { noremap = true, silent = true, desc = "Debug toggle UI" })
keymap.set("n", "<leader>de", function()
with_dapui(function(dapui)
dapui.eval()
end)
end, { noremap = true, silent = true, desc = "Debug eval" })
keymap.set("n", "<leader>dh", function()
with_dap(function()
require("dap.ui.widgets").hover()
end)
end, { noremap = true, silent = true, desc = "Debug hover" })
keymap.set("n", "<leader>dq", function()
with_dap(function(dap)
dap.repl.open()
end)
end, { noremap = true, silent = true, desc = "Debug open REPL" })
keymap.set("n", "<leader>dQ", function()
with_dap(function(dap)
dap.repl.toggle()
end)
end, { noremap = true, silent = true, desc = "Debug toggle REPL" })
keymap.set("n", "<leader>ds", function()
with_dap(function(dap)
local session = dap.session()
if session then
vim.notify("DAP session active", vim.log.levels.INFO)
else
vim.notify("No active DAP session", vim.log.levels.WARN)
end
end)
end, { noremap = true, silent = true, desc = "Debug session status" })
keymap.set("n", "<leader>df", "<cmd>Telescope dap frames<CR>", { noremap = true, silent = true, desc = "Debug frames" })
keymap.set("n", "<leader>dC", "<cmd>Telescope dap commands<CR>", { noremap = true, silent = true, desc = "Debug commands" })
keymap.set("n", "<leader>dv", "<cmd>Telescope dap variables<CR>", { noremap = true, silent = true, desc = "Debug variables" })
keymap.set("n", "<leader>dR", "<cmd>Telescope dap configurations<CR>", { noremap = true, silent = true, desc = "Debug configurations" })
keymap.set("n", "<leader>dK", "<cmd>Telescope dap list_breakpoints<CR>", { noremap = true, silent = true, desc = "Debug breakpoints" })
keymap.set("n", "<leader>cg", "<cmd>CMakeGenerate<CR>", { noremap = true, silent = true, desc = "CMake generate" })
keymap.set("n", "<leader>cb", function()
with_toggleterm(function(toggleterm)
toggleterm.run_build()
end)
end, { noremap = true, silent = true, desc = "CMake build (terminal)" })
keymap.set("n", "<leader>cB", "<cmd>CMakeBuild!<CR>", { noremap = true, silent = true, desc = "CMake clean build" })
keymap.set("n", "<leader>cc", "<cmd>CMakeClean<CR>", { noremap = true, silent = true, desc = "CMake clean" })
keymap.set("n", "<leader>ct", "<cmd>CMakeSelectBuildTarget<CR>", { noremap = true, silent = true, desc = "CMake select build target" })
keymap.set("n", "<leader>cT", "<cmd>CMakeSelectBuildType<CR>", { noremap = true, silent = true, desc = "CMake select build type" })
keymap.set("n", "<leader>cr", "<cmd>CMakeRun<CR>", { noremap = true, silent = true, desc = "CMake run" })
keymap.set("n", "<leader>cd", "<cmd>CMakeDebug<CR>", { noremap = true, silent = true, desc = "CMake debug" })
keymap.set("n", "<leader>cL", "<cmd>CMakeSelectLaunchTarget<CR>", { noremap = true, silent = true, desc = "CMake select launch target" })
keymap.set("n", "<leader>cS", "<cmd>CMakeSettings<CR>", { noremap = true, silent = true, desc = "CMake settings" })

13
lua/core/lazy.lua Normal file
View File

@@ -0,0 +1,13 @@
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",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- load plugin list
require("lazy").setup(require("plugins"))

16
lua/core/options.lua Normal file
View File

@@ -0,0 +1,16 @@
-- core/options.lua
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.termguicolors = true
vim.opt.expandtab = false
vim.opt.shiftwidth = 4
vim.opt.tabstop = 8
vim.opt.colorcolumn = "80"
vim.opt.clipboard="unnamedplus"
vim.g.mapleader = " "
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.clipboard = "unnamedplus"
vim.o.undofile = true
vim.o.undodir = vim.fn.stdpath("data") .. "/undo//"

3
lua/init.lua Normal file
View File

@@ -0,0 +1,3 @@
-- Load core config
require("core")

24
lua/lazy-lock.json Normal file
View File

@@ -0,0 +1,24 @@
{
"LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gruvbox-material": { "branch": "master", "commit": "834dbf21836862300ced7444db4262b796330ab7" },
"indentmini.nvim": { "branch": "main", "commit": "e0f1e381a3949ea6757365fa33f8f1722d3eae90" },
"lazy.nvim": { "branch": "main", "commit": "59334064f8604ca073791c25dcc5c9698865406e" },
"lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" },
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-lsp-installer": { "branch": "main", "commit": "17e0bfa5f2c8854d1636fcd036dc8284db136baa" },
"nvim-lspconfig": { "branch": "master", "commit": "e688b486fe9291f151eae7e5c0b5a5c4ef980847" },
"nvim-tree.lua": { "branch": "master", "commit": "e397756d2a79d74314ea4cd3efc41300e91c0ff0" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"venn.nvim": { "branch": "main", "commit": "b09c2f36ddf70b498281845109bedcf08a7e0de0" }
}

View File

@@ -0,0 +1,14 @@
require("cmake-tools").setup({
cmake_build_directory = "build",
cmake_generate_options = { "-DCMAKE_EXPORT_COMPILE_COMMANDS=1" },
cmake_build_options = {},
cmake_soft_link_compile_commands = true,
cmake_compile_commands_from_lsp = false,
cmake_dap_configuration = {
name = "cpp",
type = "codelldb",
request = "launch",
stopOnEntry = false,
runInTerminal = false,
},
})

View File

@@ -0,0 +1,43 @@
local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = 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" }),
["<S-Tab>"] = 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" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
}),
})

View File

@@ -0,0 +1,34 @@
local conform = require("conform")
conform.setup({
formatters_by_ft = {
c = { "clang_format" },
cpp = { "clang_format" },
h = { "clang_format" },
hpp = { "clang_format" },
},
format_on_save = function(bufnr)
local ft = vim.bo[bufnr].filetype
local cpp_filetypes = {
c = true,
cpp = true,
h = true,
hpp = true,
}
if cpp_filetypes[ft] then
return {
timeout_ms = 1000,
lsp_format = "fallback",
}
end
end,
})
vim.api.nvim_create_user_command("Format", function()
conform.format({
async = false,
timeout_ms = 1000,
lsp_format = "fallback",
})
end, {})

113
lua/plugins/config/dap.lua Normal file
View File

@@ -0,0 +1,113 @@
local dap = require("dap")
local dapui = require("dapui")
local function resolve_codelldb()
local mason_codelldb = vim.fn.stdpath("data") .. "/mason/bin/codelldb"
if vim.fn.executable(mason_codelldb) == 1 then
return mason_codelldb
end
local system_codelldb = vim.fn.exepath("codelldb")
if system_codelldb ~= "" then
return system_codelldb
end
return "codelldb"
end
require("nvim-dap-virtual-text").setup({
commented = true,
})
dap.adapters.codelldb = {
type = "server",
port = "${port}",
executable = {
command = resolve_codelldb(),
args = { "--port", "${port}" },
},
}
dap.configurations.cpp = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = function()
local input = vim.fn.input("Program args: ")
if input == "" then
return {}
end
return vim.split(input, " ")
end,
runInTerminal = false,
},
}
dap.configurations.c = dap.configurations.cpp
vim.fn.sign_define("DapBreakpoint", {
text = "",
texthl = "DiagnosticError",
linehl = "",
numhl = "",
})
vim.fn.sign_define("DapBreakpointCondition", {
text = "",
texthl = "DiagnosticWarn",
linehl = "",
numhl = "",
})
vim.fn.sign_define("DapLogPoint", {
text = "",
texthl = "DiagnosticInfo",
linehl = "",
numhl = "",
})
vim.fn.sign_define("DapStopped", {
text = "",
texthl = "DiagnosticOk",
linehl = "Visual",
numhl = "DiagnosticOk",
})
dapui.setup({
layouts = {
{
elements = {
{ id = "scopes", size = 0.30 },
{ id = "breakpoints", size = 0.20 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 0.25 },
},
size = 45,
position = "left",
},
{
elements = {
{ id = "repl", size = 0.50 },
{ id = "console", size = 0.50 },
},
size = 12,
position = "bottom",
},
},
})
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
pcall(function()
require("telescope").load_extension("dap")
end)

View File

@@ -0,0 +1,47 @@
--local lspconfig = require("lspconfig")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
-- Setup capabilities for nvim-cmp completion
local capabilities = cmp_nvim_lsp.default_capabilities()
-- Common on_attach function to map keys after LSP attaches to buffer
local on_attach = function(client, bufnr)
local bufmap = function(mode, lhs, rhs)
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, { noremap = true, silent = true })
end
-- LSP-related keymaps
bufmap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>")
bufmap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>")
bufmap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>")
bufmap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>")
bufmap("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>")
bufmap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>")
bufmap("n", "<leader>f", "<cmd>lua vim.lsp.buf.format()<CR>")
end
-- List of servers to setup
local servers = {
"pyright",
"clangd",
"zls",
"lua_ls",
"vimls",
"marksman",
"texlab",
}
local server_overrides = {
clangd = {
cmd = { "clangd", "--clang-tidy" },
},
}
for _, server in ipairs(servers) do
vim.lsp.config(server, vim.tbl_deep_extend("force", {
on_attach = on_attach,
capabilities = capabilities,
}, server_overrides[server] or {}))
-- Enable the server configuration
vim.lsp.enable(server)
end

View File

@@ -0,0 +1,8 @@
require("lualine").setup({
options = {
theme = "auto",
section_separators = "",
component_separators = "",
},
})

View File

@@ -0,0 +1,14 @@
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"pyright",
"clangd",
"zls",
"lua_ls",
"vimls",
"marksman",
"texlab",
},
automatic_installation = true,
})

View File

@@ -0,0 +1,65 @@
local lib = require("neotest.lib")
local has_cpp_parser = false
local ok_parsers, parsers = pcall(require, "nvim-treesitter.parsers")
if ok_parsers and parsers.has_parser then
has_cpp_parser = parsers.has_parser("cpp")
end
if not has_cpp_parser then
vim.schedule(function()
vim.notify(
"neotest-gtest needs Treesitter cpp parser. Run :TSInstall cpp",
vim.log.levels.WARN
)
end)
return
end
require("neotest").setup({
adapters = {
require("neotest-gtest").setup({
root = lib.files.match_root_pattern(
"CMakeLists.txt",
".git"
),
debug_adapter = "codelldb",
is_test_file = function(file)
local normalized = file:gsub("\\", "/")
local is_in_tests_dir = normalized:match("/tests/") ~= nil
local has_test_suffix = normalized:match("_test%.cpp$")
or normalized:match("_test%.cc$")
or normalized:match("_test%.cxx$")
or normalized:match("_test%.c%+%+$")
return is_in_tests_dir and has_test_suffix ~= nil
end,
filter_dir = function(name, rel_path)
if rel_path == "" then
return true
end
local blocked = {
[".git"] = true,
[".cache"] = true,
["build"] = true,
["out"] = true,
["_deps"] = true,
}
if blocked[name] then
return false
end
if rel_path:match("^build/") or rel_path:match("^out/") then
return false
end
return true
end,
mappings = {
configure = "C",
},
}),
},
})

View File

@@ -0,0 +1,8 @@
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = { width = 30 },
renderer = { group_empty = true },
filters = { dotfiles = true },
})
vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>", { noremap = true, silent = true })

View File

@@ -0,0 +1,11 @@
---@type opencode.Opts
vim.g.opencode_opts = {
-- Your configuration, if any.
}
-- Required for `opts.events.reload`.
vim.o.autoread = true
vim.keymap.set({ "n", "x" }, "<leader>oa", function()
require("opencode").ask("@this: ", { submit = true })
end, { desc = "Ask opencode with selection" })

View File

@@ -0,0 +1,117 @@
local toggleterm = require("toggleterm")
local Terminal = require("toggleterm.terminal").Terminal
toggleterm.setup({
start_in_insert = true,
insert_mappings = true,
terminal_mappings = true,
persist_size = true,
persist_mode = true,
close_on_exit = false,
direction = "horizontal",
size = 14,
})
local M = {}
local runners = {
build = {
cmd = "cmake --build --preset debug-with-tidy",
title = "Build",
},
test = {
cmd = "ctest --test-dir build --output-on-failure",
title = "Tests",
},
}
local terminals = {
shell = Terminal:new({
hidden = true,
close_on_exit = false,
direction = "horizontal",
}),
}
local last_runner = nil
local function run_in_terminal(term, cmd)
term:open()
vim.defer_fn(function()
term:send(cmd .. "\r", false)
end, 20)
end
local function project_root()
local current_file = vim.api.nvim_buf_get_name(0)
local start_path = current_file ~= "" and vim.fs.dirname(current_file) or vim.loop.cwd()
local markers = { "CMakePresets.json", "CMakeLists.txt", ".git" }
local found = vim.fs.find(markers, { upward = true, path = start_path })[1]
if found then
return vim.fs.dirname(found)
end
return vim.loop.cwd()
end
local function get_runner_term(name)
if terminals[name] then
return terminals[name]
end
terminals[name] = Terminal:new({
hidden = true,
close_on_exit = false,
direction = "horizontal",
display_name = runners[name].title,
})
return terminals[name]
end
function M.toggle_shell()
terminals.shell.dir = project_root()
terminals.shell:toggle()
end
function M.run_build()
local term = get_runner_term("build")
term.dir = project_root()
run_in_terminal(term, runners.build.cmd)
last_runner = "build"
end
function M.run_tests()
local term = get_runner_term("test")
term.dir = project_root()
run_in_terminal(term, runners.test.cmd)
last_runner = "test"
end
function M.rerun_last()
if not last_runner then
vim.notify("No build/test command has been run yet", vim.log.levels.WARN)
return
end
if last_runner == "build" then
M.run_build()
else
M.run_tests()
end
end
function M.toggle_build_terminal()
local term = get_runner_term("build")
term.dir = project_root()
term:toggle()
end
function M.toggle_test_terminal()
local term = get_runner_term("test")
term.dir = project_root()
term:toggle()
end
return M

View File

@@ -0,0 +1,41 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the listed parsers MUST always be installed)
ensure_installed = { "c", "cpp", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline", "zig" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (or "all")
ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}

View File

@@ -0,0 +1,3 @@
require("trouble").setup({
focus = false,
})

View File

@@ -0,0 +1,29 @@
-- Function to toggle venn keymaps
function _G.Toggle_venn()
local venn_enabled = vim.inspect(vim.b.venn_enabled)
if venn_enabled == "nil" then
vim.b.venn_enabled = true
vim.cmd([[setlocal ve=all]])
-- Draw a line on HJKL keystrokes
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true, silent = true })
-- Draw a box with visual selection
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true, silent = true })
else
vim.cmd([[setlocal ve=]])
vim.api.nvim_buf_del_keymap(0, "n", "J")
vim.api.nvim_buf_del_keymap(0, "n", "K")
vim.api.nvim_buf_del_keymap(0, "n", "L")
vim.api.nvim_buf_del_keymap(0, "n", "H")
vim.api.nvim_buf_del_keymap(0, "v", "f")
vim.b.venn_enabled = nil
end
end
-- Toggle venn with <leader>v globally
vim.api.nvim_set_keymap("n", "<leader>v", ":lua Toggle_venn()<CR>", { noremap = true, silent = true })

View File

@@ -0,0 +1,40 @@
local wk = require("which-key")
wk.setup({
plugins = {
presets = {
operators = false,
motions = false,
text_objects = false,
windows = false,
nav = false,
z = false,
g = false,
},
},
triggers = {
{ "<leader>", mode = { "n", "v" } },
},
})
if wk.add then
wk.add({
{ "<leader>c", group = "CMake" },
{ "<leader>d", group = "Debug" },
{ "<leader>f", group = "Find" },
{ "<leader>m", group = "Build" },
{ "<leader>o", group = "OpenCode" },
{ "<leader>t", group = "Tests" },
{ "<leader>x", group = "Problems" },
})
else
wk.register({
c = { name = "+CMake" },
d = { name = "+Debug" },
f = { name = "+Find" },
m = { name = "+Build" },
o = { name = "+OpenCode" },
t = { name = "+Tests" },
x = { name = "+Problems" },
}, { prefix = "<leader>" })
end

195
lua/plugins/init.lua Normal file
View File

@@ -0,0 +1,195 @@
return {
{
"nvim-treesitter/nvim-treesitter",
branch = 'master',
lazy = false,
build = ":TSUpdate",
config = function()
require("plugins.config.treesitter")
end,
},
{
"nvim-tree/nvim-tree.lua",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("plugins.config.nvimtree")
end,
},
{
"nvim-lualine/lualine.nvim",
config = function()
require("plugins.config.lualine")
end,
},
{
"sainnhe/gruvbox-material",
config = function()
vim.cmd([[colorscheme gruvbox-material]])
end,
},
{
"neovim/nvim-lspconfig",
dependencies = {
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
{
"williamboman/mason.nvim",
config = function()
require("plugins.config.mason")
end,
},
{
"williamboman/mason-lspconfig.nvim",
},
},
config = function()
require("plugins.config.lsp")
end,
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
},
config = function()
require("plugins.config.cmp")
end,
},
{
"stevearc/conform.nvim",
config = function()
require("plugins.config.conform")
end,
},
{
'nvim-telescope/telescope.nvim', tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("plugins.config.trouble")
end,
},
{
"akinsho/toggleterm.nvim",
config = function()
require("plugins.config.toggleterm")
end,
},
{
"folke/which-key.nvim",
config = function()
require("plugins.config.whichkey")
end,
},
{
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
"nvim-neotest/nvim-nio",
"theHamsta/nvim-dap-virtual-text",
"nvim-telescope/telescope-dap.nvim",
},
config = function()
require("plugins.config.dap")
end,
},
{
"nvim-neotest/neotest",
dependencies = {
"nvim-neotest/nvim-nio",
"nvim-lua/plenary.nvim",
"alfaix/neotest-gtest",
},
config = function()
require("plugins.config.neotest")
end,
},
{
"Civitasv/cmake-tools.nvim",
config = function()
require("plugins.config.cmake")
end,
},
{
'nvimdev/indentmini.nvim',
config = function()
require("indentmini").setup() -- use default config
vim.cmd('hi default link IndentLine Comment')
vim.cmd.highlight('IndentLine guifg=#89b482')
vim.cmd.highlight('IndentLineCurrent guifg=#e78a4e')
end,
},
{
'jbyuki/venn.nvim',
config = function()
require("plugins.config.venn")
end,
},
{
"iamcco/markdown-preview.nvim",
build = "cd app && npm install",
cmd = { "MarkdownPreview", "MarkdownPreviewToggle", "MarkdownPreviewStop" },
ft = { "markdown" },
config = function()
vim.g.mkdp_auto_start = 0
vim.g.mkdp_auto_close = 1
vim.g.mkdp_browser = "/usr/bin/zen-browser"
vim.g.mkdp_theme = "dark"
end,
},
{ "f-person/git-blame.nvim" },
{ "lewis6991/gitsigns.nvim" },
{
"hedyhli/markdown-toc.nvim",
ft = "markdown", -- Lazy load on markdown filetype
cmd = { "Mtoc" }, -- Or, lazy load on "Mtoc" command
opts = {
-- Your configuration here (optional)
},
},
{
"vimwiki/vimwiki",
config = function()
vim.g.vimwiki_list = {
{
path = "~/vimwiki/",
syntax = "markdown",
ext = ".md",
},
}
vim.g.vimwiki_ext2syntax = {
[".md"] = "markdown",
[".markdown"] = "markdown",
[".mdown"] = "markdown",
}
end,
},
{
"nickjvandyke/opencode.nvim",
dependencies = {
-- Recommended for `ask()` and `select()`.
-- Required for `snacks` provider.
---@module 'snacks' <- Loads `snacks.nvim` types for configuration intellisense.
{ "folke/snacks.nvim", opts = { input = {}, picker = {}, terminal = {} } },
},
config = function()
require("plugins.config.opencode")
end,
}
}

View File

@@ -1,130 +0,0 @@
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
--   פּ ﯟ   some other good icons
local kind_icons = {
Text = "",
Method = "m",
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 = {
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = 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.
["<CR>"] = cmp.mapping.confirm { select = true },
["<Tab>"] = 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",
}),
["<S-Tab>"] = 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)
-- Kind icons
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
},
experimental = {
ghost_text = false,
native_menu = false,
},
}

View File

@@ -1,8 +0,0 @@
vim.cmd [[
try
colorscheme gruvbox-material
catch /^Vim\%((\a\+)\)\=:E185/
colorscheme default
set background=dark
endtry
]]

View File

@@ -1,48 +0,0 @@
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`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
interval = 1000,
follow_files = true,
},
attach_to_untracked = true,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
},
current_line_blame_formatter_opts = {
relative_time = false,
},
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000,
preview_config = {
-- Options passed to nvim_open_win
border = "single",
style = "minimal",
relative = "cursor",
row = 0,
col = 1,
},
yadm = {
enable = false,
},
}

View File

@@ -1,38 +0,0 @@
local opts = { noremap = true, silent = true }
local term_opts = { silent = true }
-- Shorten function name
local keymap = vim.api.nvim_set_keymap
--Remap space as leader key
keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- 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", "<leader>h", ":wincmd h<CR>", opts)
keymap("n", "<leader>j", ":wincmd j<CR>", opts)
keymap("n", "<leader>k", ":wincmd k<CR>", opts)
keymap("n", "<leader>l", ":wincmd l<CR>", opts)
keymap("n", "<C-n>", ":NvimTreeToggle<CR>", opts)
-- window size up / down
keymap("n", "<leader>+", ":vertical resize +5<CR>", opts)
keymap("n", "<leader>-", ":vertical resize -5<CR>", opts)
-- Telescope
keymap("n", "<leader>ff" , "<cmd>lua require('telescope.builtin').find_files({hidden = true})<cr>",opts)
keymap("n", "<leader>fg" , "<cmd>lua require('telescope.builtin').live_grep()<cr>",opts)
keymap("n", "<leader>fb" , "<cmd>lua require('telescope.builtin').buffers()<cr>",opts)
keymap("n", "<leader>fh" , "<cmd>lua require('telescope.builtin').help_tags()<cr>",opts)

View File

@@ -1,24 +0,0 @@
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if not status_ok then
return
end
local lspconfig = require("lspconfig")
local servers = { "jsonls", "sumneko_lua" , "pyright", "gopls", "ccls"}
lsp_installer.setup({
ensure_installed = servers,
})
for _, server in pairs(servers) do
local opts = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
}
local has_custom_opts, server_custom_opts = pcall(require, "user.lsp.settings." .. server)
if has_custom_opts then
opts = vim.tbl_deep_extend("force", opts, server_custom_opts)
end
lspconfig[server].setup(opts)
end

View File

@@ -1,102 +0,0 @@
local M = {}
-- TODO: backfill this to template
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 = {
-- disable virtual text
virtual_text = false,
-- show signs
signs = {
active = signs,
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = false,
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",
width = 60,
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded",
width = 60,
})
end
local function lsp_highlight_document(client)
-- Set autocommands conditional on server_capabilities
local status_ok, illuminate = pcall(require, "illuminate")
if not status_ok then
return
end
illuminate.on_attach(client)
-- end
end
local function lsp_keymaps(bufnr)
local opts = { noremap = true, silent = true }
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
vim.api.nvim_buf_set_keymap(
bufnr,
"n",
"gl",
'<cmd>lua vim.diagnostic.open_float({ border = "rounded" })<CR>',
opts
)
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]])
end
M.on_attach = function(client, bufnr)
-- vim.notify(client.name .. " starting...")
-- TODO: refactor this into a method that checks if string in list
if client.name == "tsserver" then
client.resolved_capabilities.document_formatting = false
end
lsp_keymaps(bufnr)
lsp_highlight_document(client)
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not status_ok then
return
end
M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities)
return M

View File

@@ -1,8 +0,0 @@
local status_ok, _ = pcall(require, "lspconfig")
if not status_ok then
return
end
require "user.lsp.configs"
require("user.lsp.handlers").setup()
require "user.lsp.null-ls"

View File

@@ -1,23 +0,0 @@
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/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/code_actions
local code_actions = null_ls.builtins.code_actions
null_ls.setup({
debug = false,
sources = {
formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
formatting.black.with({ extra_args = { "--fast" } }),
formatting.stylua,
--diagnostics.flake8,
diagnostics.cppcheck,
code_actions.refactoring
},
})

View File

@@ -1,197 +0,0 @@
local default_schemas = nil
local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls")
if status_ok then
default_schemas = jsonls_settings.get_default_schemas()
end
local schemas = {
{
description = "TypeScript compiler configuration file",
fileMatch = {
"tsconfig.json",
"tsconfig.*.json",
},
url = "https://json.schemastore.org/tsconfig.json",
},
{
description = "Lerna config",
fileMatch = { "lerna.json" },
url = "https://json.schemastore.org/lerna.json",
},
{
description = "Babel configuration",
fileMatch = {
".babelrc.json",
".babelrc",
"babel.config.json",
},
url = "https://json.schemastore.org/babelrc.json",
},
{
description = "ESLint config",
fileMatch = {
".eslintrc.json",
".eslintrc",
},
url = "https://json.schemastore.org/eslintrc.json",
},
{
description = "Bucklescript config",
fileMatch = { "bsconfig.json" },
url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json",
},
{
description = "Prettier config",
fileMatch = {
".prettierrc",
".prettierrc.json",
"prettier.config.json",
},
url = "https://json.schemastore.org/prettierrc",
},
{
description = "Vercel Now config",
fileMatch = { "now.json" },
url = "https://json.schemastore.org/now",
},
{
description = "Stylelint config",
fileMatch = {
".stylelintrc",
".stylelintrc.json",
"stylelint.config.json",
},
url = "https://json.schemastore.org/stylelintrc",
},
{
description = "A JSON schema for the ASP.NET LaunchSettings.json files",
fileMatch = { "launchsettings.json" },
url = "https://json.schemastore.org/launchsettings.json",
},
{
description = "Schema for CMake Presets",
fileMatch = {
"CMakePresets.json",
"CMakeUserPresets.json",
},
url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json",
},
{
description = "Configuration file as an alternative for configuring your repository in the settings page.",
fileMatch = {
".codeclimate.json",
},
url = "https://json.schemastore.org/codeclimate.json",
},
{
description = "LLVM compilation database",
fileMatch = {
"compile_commands.json",
},
url = "https://json.schemastore.org/compile-commands.json",
},
{
description = "Config file for Command Task Runner",
fileMatch = {
"commands.json",
},
url = "https://json.schemastore.org/commands.json",
},
{
description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.",
fileMatch = {
"*.cf.json",
"cloudformation.json",
},
url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json",
},
{
description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.",
fileMatch = {
"serverless.template",
"*.sam.json",
"sam.json",
},
url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json",
},
{
description = "Json schema for properties json file for a GitHub Workflow template",
fileMatch = {
".github/workflow-templates/**.properties.json",
},
url = "https://json.schemastore.org/github-workflow-template-properties.json",
},
{
description = "golangci-lint configuration file",
fileMatch = {
".golangci.toml",
".golangci.json",
},
url = "https://json.schemastore.org/golangci-lint.json",
},
{
description = "JSON schema for the JSON Feed format",
fileMatch = {
"feed.json",
},
url = "https://json.schemastore.org/feed.json",
versions = {
["1"] = "https://json.schemastore.org/feed-1.json",
["1.1"] = "https://json.schemastore.org/feed.json",
},
},
{
description = "Packer template JSON configuration",
fileMatch = {
"packer.json",
},
url = "https://json.schemastore.org/packer.json",
},
{
description = "NPM configuration file",
fileMatch = {
"package.json",
},
url = "https://json.schemastore.org/package.json",
},
{
description = "JSON schema for Visual Studio component configuration files",
fileMatch = {
"*.vsconfig",
},
url = "https://json.schemastore.org/vsconfig.json",
},
{
description = "Resume json",
fileMatch = { "resume.json" },
url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
},
}
local function extend(tab1, tab2)
for _, value in ipairs(tab2 or {}) do
table.insert(tab1, value)
end
return tab1
end
local extended_schemas = extend(schemas, default_schemas)
local opts = {
settings = {
json = {
schemas = extended_schemas,
},
},
setup = {
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
end,
},
},
},
}
return opts

View File

@@ -1,16 +0,0 @@
return {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
}

View File

@@ -1,93 +0,0 @@
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,
update_in_insert = false,
always_visible = true,
}
local diff = {
"diff",
colored = false,
symbols = { added = "", modified = "", removed = "" }, -- changes diff symbols
cond = hide_in_width
}
local mode = {
"mode",
fmt = function(str)
return "-- " .. str .. " --"
end,
}
local filetype = {
"filetype",
icons_enabled = false,
icon = nil,
}
local branch = {
"branch",
icons_enabled = true,
icon = "",
}
local location = {
"location",
padding = 0,
}
-- cool function for progress
local progress = function()
local current_line = vim.fn.line(".")
local total_lines = vim.fn.line("$")
local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
return chars[index]
end
local spaces = function()
return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
lualine.setup({
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = { "alpha", "dashboard", "NvimTree", "Outline" },
always_divide_middle = true,
},
sections = {
lualine_a = { branch, diagnostics },
lualine_b = { mode },
lualine_c = {},
-- lualine_x = { "encoding", "fileformat", "filetype" },
lualine_x = { diff, spaces, "encoding", filetype },
lualine_y = { location },
lualine_z = { progress },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})

View File

@@ -1,68 +0,0 @@
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,
height = 30,
side = "left",
mappings = {
list = {
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
{ key = "h", cb = tree_cb "close_node" },
{ key = "v", cb = tree_cb "vsplit" },
},
},
},
}

View File

@@ -1,40 +0,0 @@
local options = {
backup = false, -- creates a backup fil
clipboard = "unnamedplus", -- allows neovim to access the system clipboard
cmdheight = 2, -- more space in the neovim command line for displaying messages
conceallevel = 0, -- so that `` is visible in markdown files
fileencoding = "utf-8", -- the encoding written to a file
hlsearch = true, -- highlight all matches on previous search pattern
ignorecase = true, -- ignore case in search patterns
mouse = "a", -- allow the mouse to be used in neovim
pumheight = 10, -- pop up menu height
termguicolors = true, -- set term gui colors
showtabline = 2, -- always show tabs
smartcase = true, -- smart case
smartindent = true, -- make indenting smarter again
splitbelow = true, -- force all horizontal splits to go below current window
splitright = true, -- force all vertical splits to go to the right of current window
swapfile = false, -- creates a swapfile
undofile = true, -- enable persistent undo
updatetime = 300, -- faster completion (4000ms default)
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
expandtab = true, -- convert tabs to spaces
shiftwidth = 4, -- the number of spaces inserted for each indentation
tabstop = 4, -- insert 2 spaces for a tab
number = true, -- set numbered lines
relativenumber = true, -- set relative numbered lines
numberwidth = 4, -- set number column width to 2 {default 4}
wrap = true, -- display lines as one long line
scrolloff = 12, -- is one of my fav
sidescrolloff = 8,
}
vim.opt.shortmess:append "c"
for k, v in pairs(options) do
vim.opt[k] = v
end
vim.cmd "set whichwrap+=<,>,[,],h,l"
vim.cmd [[set iskeyword+=-]]
vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work

View File

@@ -1,85 +0,0 @@
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 <afile> | 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
--Install plugins here
return packer.startup(function(use)
-- General Libs
use "wbthomason/packer.nvim" -- Have packer manage itself
use "nvim-lua/popup.nvim" -- Popup API of vim in Neovim
use "nvim-lua/plenary.nvim" -- Lua lib required by other plugins
-- Colorschemes
use "sainnhe/gruvbox-material"
use {'shaunsingh/oxocarbon.nvim', run = './install.sh'}
--cmp plugins
use "hrsh7th/nvim-cmp" -- The completion plugin
use "hrsh7th/cmp-buffer" -- buffer completions
use "hrsh7th/cmp-path" -- path completions
use "saadparwaiz1/cmp_luasnip" -- snippet completions
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-nvim-lua"
-- snippets
use "L3MON4D3/LuaSnip" --snippet engine
use "rafamadriz/friendly-snippets" -- a bunch of snippets to use
-- LSP
use "neovim/nvim-lspconfig" -- enable LSP
use "williamboman/nvim-lsp-installer" -- simple to use language server installer
use "jose-elias-alvarez/null-ls.nvim" -- for formatters and linters
-- Telescope
use "nvim-telescope/telescope.nvim"
-- TreeSitter
use { "nvim-treesitter/nvim-treesitter" , run = "TSUpdate",}
-- Git Stuff
use "lewis6991/gitsigns.nvim"
use "f-person/git-blame.nvim"
use "tpope/vim-fugitive"
-- nvim-tree
use "kyazdani42/nvim-tree.lua"
-- toggleterm
use "akinsho/toggleterm.nvim"
-- lualine
use "nvim-lualine/lualine.nvim"
--markdown
use({ "iamcco/markdown-preview.nvim", run = "cd app && npm install", setup = function() vim.g.mkdp_filetypes = { "markdown" } end, ft = { "markdown" }, })
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)

View File

@@ -1,96 +0,0 @@
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end
local actions = require "telescope.actions"
telescope.setup {
defaults = {
prompt_prefix = "",
selection_caret = "",
path_display = { "smart" },
mappings = {
i = {
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-c>"] = actions.close,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["<CR>"] = actions.select_default,
["<C-x>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
["<PageUp>"] = actions.results_scrolling_up,
["<PageDown>"] = actions.results_scrolling_down,
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
["<C-l>"] = actions.complete_tag,
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
},
n = {
["<esc>"] = actions.close,
["<CR>"] = actions.select_default,
["<C-x>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
["j"] = actions.move_selection_next,
["k"] = actions.move_selection_previous,
["H"] = actions.move_to_top,
["M"] = actions.move_to_middle,
["L"] = actions.move_to_bottom,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["gg"] = actions.move_to_top,
["G"] = actions.move_to_bottom,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
["<PageUp>"] = actions.results_scrolling_up,
["<PageDown>"] = actions.results_scrolling_down,
["?"] = actions.which_key,
},
},
},
pickers = {
-- Default configuration for builtin pickers goes here:
-- picker_name = {
-- picker_config_key = value,
-- ...
-- }
-- Now the picker_config_key will be applied every time you call this
-- builtin picker
},
extensions = {
-- Your extension configuration goes here:
-- extension_name = {
-- extension_config_key = value,
-- }
-- please take a look at the readme of the extension you want to configure
},
}

View File

@@ -1,40 +0,0 @@
local status_ok, toggleterm = pcall(require, "toggleterm")
if not status_ok then
return
end
toggleterm.setup({
size = 20,
open_mapping = [[<c-\>]],
hide_numbers = true,
shade_filetypes = {},
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",
winblend = 0,
highlights = {
border = "Normal",
background = "Normal",
},
},
})
function _G.set_terminal_keymaps()
local opts = {noremap = true}
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
end
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')

View File

@@ -1,17 +0,0 @@
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end
configs.setup({
ensure_installed = "all", -- one of "all" or a list of languages
ignore_install = { "" }, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension
disable = { "" }, -- list of language that will be disabled
},
autopairs = {
enable = true,
},
indent = { enable = true, disable = { "" } },
})

14
lua/utils/reload.lua Normal file
View File

@@ -0,0 +1,14 @@
local M = {}
function M.reload()
for name, _ in pairs(package.loaded) do
if name:match("^core") or name:match("^plugins") or name == "init" then
package.loaded[name] = nil
end
end
dofile(vim.env.MYVIMRC)
vim.notify("Config reloaded!", vim.log.levels.INFO)
end
return M

View File

@@ -1,232 +0,0 @@
-- 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 = "/home/alican/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/alican/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/alican/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/alican/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/alican/.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 = {
LuaSnip = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/LuaSnip",
url = "https://github.com/L3MON4D3/LuaSnip"
},
["cmp-buffer"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/cmp-buffer",
url = "https://github.com/hrsh7th/cmp-buffer"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["cmp-nvim-lua"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua",
url = "https://github.com/hrsh7th/cmp-nvim-lua"
},
["cmp-path"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path"
},
cmp_luasnip = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/cmp_luasnip",
url = "https://github.com/saadparwaiz1/cmp_luasnip"
},
["friendly-snippets"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/friendly-snippets",
url = "https://github.com/rafamadriz/friendly-snippets"
},
["git-blame.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/git-blame.nvim",
url = "https://github.com/f-person/git-blame.nvim"
},
["gitsigns.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
url = "https://github.com/lewis6991/gitsigns.nvim"
},
["gruvbox-material"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/gruvbox-material",
url = "https://github.com/sainnhe/gruvbox-material"
},
["lualine.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim"
},
["markdown-preview.nvim"] = {
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/alican/.local/share/nvim/site/pack/packer/opt/markdown-preview.nvim",
url = "https://github.com/iamcco/markdown-preview.nvim"
},
["null-ls.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/null-ls.nvim",
url = "https://github.com/jose-elias-alvarez/null-ls.nvim"
},
["nvim-cmp"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-lsp-installer"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer",
url = "https://github.com/williamboman/nvim-lsp-installer"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-tree.lua"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
url = "https://github.com/kyazdani42/nvim-tree.lua"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["oxocarbon.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/oxocarbon.nvim",
url = "https://github.com/shaunsingh/oxocarbon.nvim"
},
["packer.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["popup.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/popup.nvim",
url = "https://github.com/nvim-lua/popup.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["toggleterm.nvim"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/toggleterm.nvim",
url = "https://github.com/akinsho/toggleterm.nvim"
},
["vim-fugitive"] = {
loaded = true,
path = "/home/alican/.local/share/nvim/site/pack/packer/start/vim-fugitive",
url = "https://github.com/tpope/vim-fugitive"
}
}
time([[Defining packer_plugins]], false)
-- Setup for: markdown-preview.nvim
time([[Setup for markdown-preview.nvim]], true)
try_loadstring("\27LJ\2\n=\0\0\2\0\4\0\0056\0\0\0009\0\1\0005\1\3\0=\1\2\0K\0\1\0\1\2\0\0\rmarkdown\19mkdp_filetypes\6g\bvim\0", "setup", "markdown-preview.nvim")
time([[Setup for markdown-preview.nvim]], false)
vim.cmd [[augroup packer_load_aucmds]]
vim.cmd [[au!]]
-- Filetype lazy-loads
time([[Defining lazy-load filetype autocommands]], true)
vim.cmd [[au FileType markdown ++once lua require("packer.load")({'markdown-preview.nvim'}, { ft = "markdown" }, _G.packer_plugins)]]
time([[Defining lazy-load filetype autocommands]], false)
vim.cmd("augroup END")
_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