diff options
author | eug-vs <eugene@eug-vs.xyz> | 2024-05-23 14:15:03 +0200 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2024-05-23 14:19:14 +0200 |
commit | 80a4d36ead3d1329925e4692cfe46498aaf08467 (patch) | |
tree | 0a1476526fa335ffd763fb738988e720e1305ae7 | |
parent | c3b4d29fb20e0d10ef792860e7fe7383e145ef9a (diff) | |
download | dotfiles-80a4d36ead3d1329925e4692cfe46498aaf08467.tar.gz |
feat(nvim): modernize configuration, all-in on lua
Major changes:
- Switch from Packer to Lazy.nvim
- Use Mason.nvim for LSP auto-install & management
- Organize plugins into recommended structure
Experimental changes:
- Use oil.nvim instead of lua filetree
- Remove startify.vim
21 files changed, 569 insertions, 510 deletions
diff --git a/nvim/.config/nvim/ftplugin/markdown.lua b/nvim/.config/nvim/ftplugin/markdown.lua new file mode 100644 index 0000000..4d56693 --- /dev/null +++ b/nvim/.config/nvim/ftplugin/markdown.lua @@ -0,0 +1,14 @@ +-- Add the key mappings only for Markdown files in a zk notebook. +if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then + local function map(...) vim.api.nvim_buf_set_keymap(0, ...) end + local opts = { noremap=true, silent=false } + + -- Open the link under the caret. + map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) + + -- Open notes linking to the current buffer. + map("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", opts) + -- Open notes linked by the current buffer. + map("n", "<leader>zl", "<Cmd>ZkLinks<CR>", opts) +end + diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..de03b5b --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,96 @@ +vim.opt.mouse = "a" +vim.opt.cursorline = true +vim.opt.termguicolors = true + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.ignorecase = true +vim.opt.smartcase = true + +vim.opt.clipboard = "unnamedplus" + +vim.opt.scrolloff = 10 + +vim.opt.smarttab = true +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.autoindent = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 + +vim.opt.laststatus = 3 + +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- TODO: revisit after experiment +vim.opt.undofile = true + +-- TODO: revisit after experiment +vim.opt.breakindent = true + +-- TODO: revisit after experiment +vim.opt.list = true +vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" } + +-- TODO: revisit after experiment +vim.opt.inccommand = "split" + +-- Windows navigation +vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" }) +vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" }) +vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" }) +vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" }) + +vim.keymap.set("n", "<leader>s", "<CMD>source %<CR>", { desc = "Source current file" }) + +-- Easier indentation +vim.keymap.set("v", "<", "<gv") +vim.keymap.set("v", ">", ">gv") + +-- Moving selection around +vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selection down" }) +vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selection up" }) + +-- Highlight on yank +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- Colorscheme +vim.g.gruvbox_material_enable_bold = 1 +vim.g.gruvbox_material_menu_selection_background = "green" +vim.g.gruvbox_material_sign_column_background = "none" +vim.g.gruvbox_material_visual = "green background" +vim.g.gruvbox_material_palette = "original" +vim.cmd.colorscheme("gruvbox-material") + +-- Diagnostic +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous [D]iagnostic message" }) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next [D]iagnostic message" }) +vim.keymap.set("n", "L", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" }) +vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" }) + +-- Lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +require("lazy").setup("plugins", { + change_detection = { + notify = false, + }, +}) diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim deleted file mode 100644 index e0ccdf8..0000000 --- a/nvim/.config/nvim/init.vim +++ /dev/null @@ -1,90 +0,0 @@ -" Neovim configuration file -" Author: eug-vs -" Email: eugene@eug-vs.xyz - -" Enter the current millenium -set nocompatible -syntax enable -filetype plugin on - -" General stuff -set number relativenumber -set ignorecase smartcase -set splitbelow splitright -set termguicolors -set cursorline -set hidden -set nowrap -set ruler -set mouse=a -set clipboard=unnamedplus -set scrolloff=3 -set conceallevel=0 -set laststatus=3 - -" Indentation -set smarttab expandtab -set smartindent autoindent -set tabstop=2 -set shiftwidth=2 -set showtabline=2 - -" Colorscheme -let g:gruvbox_material_enable_bold = 1 -let g:gruvbox_material_menu_selection_background = 'green' -let g:gruvbox_material_sign_column_background = 'none' -let g:gruvbox_material_visual = 'green background' -let g:gruvbox_material_palette = 'original' -colorscheme gruvbox-material - -" Built-in fuzzy-finder -set path=.,** -set wildmenu -set wildignore+=**/node_modules/**,**/build/**,**/dist/**,**/__pycache__/** -set wildmode=longest,list,full -set completeopt=menu,menuone,noselect - -" Easier window navigation -nnoremap <c-h> <C-w>h -nnoremap <c-j> <C-w>j -nnoremap <c-k> <C-w>k -nnoremap <c-l> <C-w>l - -" Easier indentation -vnoremap < <gv -vnoremap > >gv - -" Moving selection -noremap <leader>k :m .-2<CR>== -noremap <leader>j :m .+1<CR>== -vnoremap J :m '>+1<CR>gv=gv -vnoremap K :m '<-2<CR>gv=gv - -" Remove trailing whitespace on save -autocmd BufWritePre * %s/\s\+$//e - -" Vimrc management -nnoremap <leader>ev :vs $MYVIMRC<CR> -nnoremap <leader>sv :source $MYVIMRC<CR> - -" Built-in terminal -autocmd TermOpen * setlocal nonumber | setlocal norelativenumber | startinsert -tnoremap <Esc> <C-\><C-n> - -" Load plugins -set runtimepath^=~/.vim runtimepath+=~/.vim/after -let &packpath = &runtimepath -lua require('plugins') - -" Telescope -" TODO: move this ugly line into a function or smth -nnoremap <silent><leader>ff :lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown({ previewer = false, find_command = { 'rg', '--files', '--iglob', '!.git', '--hidden' } }))<CR> -nnoremap <silent><Leader>fr :Telescope live_grep<CR> - -source ~/.config/nvim/startify.vim -source ~/.config/nvim/vimwiki.vim - -lua require('lsp-config') -lua require('completion') -lua require('treesitter') -lua require('filetree') diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..f1c5c22 --- /dev/null +++ b/nvim/.config/nvim/lazy-lock.json @@ -0,0 +1,41 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "f3b930db4964d60e255c8f9e37b7f2218dfc08cb" }, + "copilot.vim": { "branch": "release", "commit": "25feddf8e3aa79f0573c8f43ddb13c44c530cfa5" }, + "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, + "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, + "gitsigns.nvim": { "branch": "main", "commit": "a28bb1db506df663b063cc63f44fbbda178255a7" }, + "gruvbox-material": { "branch": "master", "commit": "aa8096277690db1e1807ec57812c2cf3d54bb37f" }, + "hardtime.nvim": { "branch": "main", "commit": "eaf4bc31b86419c26ad7b3a142dd36ca545ca2e4" }, + "lazy.nvim": { "branch": "main", "commit": "8f19915175395680808de529e4220da8dafc0759" }, + "lspkind-nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a4caa0d083aab56f6cd5acf2d42331b74614a585" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c1fbdcb0d8d1295314f1612c4a247253e70299d9" }, + "mason.nvim": { "branch": "main", "commit": "49ff59aded1047a773670651cfa40e76e63c6377" }, + "neodev.nvim": { "branch": "main", "commit": "ce9a2e8eaba5649b553529c5498acb43a6c317cd" }, + "nui.nvim": { "branch": "main", "commit": "b1b3dcd6ed8f355c78bad3d395ff645be5f8b6ae" }, + "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, + "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, + "nvim-lspconfig": { "branch": "master", "commit": "eadcee1573ca9d0e0cd36a49f620186a8dfdc607" }, + "nvim-treesitter": { "branch": "master", "commit": "30de5e7e9486fb1b1b8c2a1e71052b13f94f1cb0" }, + "nvim-ts-autotag": { "branch": "main", "commit": "8ae54b90e36ef1fc5267214b30c2cbff71525fe4" }, + "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, + "oil.nvim": { "branch": "master", "commit": "2cb39e838e9dcd8b374f09a3a87a2e5ec9d372f6" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "4aed63995a69e343b068c7469491a8d1592c339f" }, + "vim-css-color": { "branch": "master", "commit": "950e80352b325ff26d3b0faf95b29e301c200f7d" }, + "vim-dadbod": { "branch": "master", "commit": "fb30422b7bee7e2fa4205a4d226f01477f4fc593" }, + "vim-dadbod-completion": { "branch": "master", "commit": "5d5ad196fcde223509d7dabbade0148f7884c5e3" }, + "vim-dadbod-ui": { "branch": "master", "commit": "5aa854ee6017e9a3463d3dc8eee5aac93739f021" }, + "vim-tmux-navigator": { "branch": "master", "commit": "c600cf10db1bf933aab9e357158bf9b202ecf99b" }, + "vim-to-github": { "branch": "master", "commit": "9ea9c75b6cd48bd42823a39c56a05a2ff8161536" }, + "zk-nvim": { "branch": "main", "commit": "e2b6d62b18a88249016bf917d4e5bb0e417ac974" } +}
\ No newline at end of file diff --git a/nvim/.config/nvim/lua/completion.lua b/nvim/.config/nvim/lua/completion.lua deleted file mode 100644 index d37061c..0000000 --- a/nvim/.config/nvim/lua/completion.lua +++ /dev/null @@ -1,41 +0,0 @@ -local cmp = require'cmp' -local lspkind = require 'lspkind' -local luasnip = require 'luasnip' -lspkind.init() - -cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - ['<C-Space>'] = cmp.mapping.complete(), - ['<C-e>'] = cmp.mapping.abort(), - ['<CR>'] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true - }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), - sources = { - { name = 'nvim_lsp' }, - { name = 'nvim_lua' }, - { name = 'path' }, - { name = 'luasnip' }, - { name = 'buffer', keyword_length = 5 }, - }, - formatting = { - format = lspkind.cmp_format { - with_text = true, - menu = { - buffer = '[buf]', - nvim_lsp = '[LSP]', - nvim_lua = '[api]', - luasnip = '[snip]', - }, - }, - }, - experimental = { - ghost_text = true, - } -}) diff --git a/nvim/.config/nvim/lua/filetree.lua b/nvim/.config/nvim/lua/filetree.lua deleted file mode 100644 index dfeb90c..0000000 --- a/nvim/.config/nvim/lua/filetree.lua +++ /dev/null @@ -1,98 +0,0 @@ -local api = require('nvim-tree.api') - -local function on_attach(bufnr) - local function opts(desc) - return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } - end - - -- BEGIN_DEFAULT_ON_ATTACH - vim.keymap.set('n', '<C-]>', api.tree.change_root_to_node, opts('CD')) - vim.keymap.set('n', '<C-e>', api.node.open.replace_tree_buffer, opts('Open: In Place')) - vim.keymap.set('n', '<C-k>', api.node.show_info_popup, opts('Info')) - vim.keymap.set('n', '<C-r>', api.fs.rename_sub, opts('Rename: Omit Filename')) - vim.keymap.set('n', '<C-t>', api.node.open.tab, opts('Open: New Tab')) - vim.keymap.set('n', '<C-v>', api.node.open.vertical, opts('Open: Vertical Split')) - vim.keymap.set('n', '<C-x>', api.node.open.horizontal, opts('Open: Horizontal Split')) - vim.keymap.set('n', '<BS>', api.node.navigate.parent_close, opts('Close Directory')) - vim.keymap.set('n', '<CR>', api.node.open.edit, opts('Open')) - vim.keymap.set('n', '<Tab>', api.node.open.preview, opts('Open Preview')) - vim.keymap.set('n', '>', api.node.navigate.sibling.next, opts('Next Sibling')) - vim.keymap.set('n', '<', api.node.navigate.sibling.prev, opts('Previous Sibling')) - vim.keymap.set('n', '.', api.node.run.cmd, opts('Run Command')) - vim.keymap.set('n', '-', api.tree.change_root_to_parent, opts('Up')) - vim.keymap.set('n', 'a', api.fs.create, opts('Create')) - vim.keymap.set('n', 'bmv', api.marks.bulk.move, opts('Move Bookmarked')) - vim.keymap.set('n', 'B', api.tree.toggle_no_buffer_filter, opts('Toggle No Buffer')) - vim.keymap.set('n', 'c', api.fs.copy.node, opts('Copy')) - vim.keymap.set('n', 'C', api.tree.toggle_git_clean_filter, opts('Toggle Git Clean')) - vim.keymap.set('n', '[c', api.node.navigate.git.prev, opts('Prev Git')) - vim.keymap.set('n', ']c', api.node.navigate.git.next, opts('Next Git')) - vim.keymap.set('n', 'd', api.fs.remove, opts('Delete')) - vim.keymap.set('n', 'D', api.fs.trash, opts('Trash')) - vim.keymap.set('n', 'E', api.tree.expand_all, opts('Expand All')) - vim.keymap.set('n', 'e', api.fs.rename_basename, opts('Rename: Basename')) - vim.keymap.set('n', ']e', api.node.navigate.diagnostics.next, opts('Next Diagnostic')) - vim.keymap.set('n', '[e', api.node.navigate.diagnostics.prev, opts('Prev Diagnostic')) - vim.keymap.set('n', 'F', api.live_filter.clear, opts('Clean Filter')) - vim.keymap.set('n', 'f', api.live_filter.start, opts('Filter')) - vim.keymap.set('n', 'g?', api.tree.toggle_help, opts('Help')) - vim.keymap.set('n', 'gy', api.fs.copy.absolute_path, opts('Copy Absolute Path')) - vim.keymap.set('n', 'H', api.tree.toggle_hidden_filter, opts('Toggle Dotfiles')) - vim.keymap.set('n', 'I', api.tree.toggle_gitignore_filter, opts('Toggle Git Ignore')) - vim.keymap.set('n', 'J', api.node.navigate.sibling.last, opts('Last Sibling')) - vim.keymap.set('n', 'K', api.node.navigate.sibling.first, opts('First Sibling')) - vim.keymap.set('n', 'm', api.marks.toggle, opts('Toggle Bookmark')) - vim.keymap.set('n', 'o', api.node.open.edit, opts('Open')) - vim.keymap.set('n', 'O', api.node.open.no_window_picker, opts('Open: No Window Picker')) - vim.keymap.set('n', 'p', api.fs.paste, opts('Paste')) - vim.keymap.set('n', 'P', api.node.navigate.parent, opts('Parent Directory')) - vim.keymap.set('n', 'q', api.tree.close, opts('Close')) - vim.keymap.set('n', 'r', api.fs.rename, opts('Rename')) - vim.keymap.set('n', 'R', api.tree.reload, opts('Refresh')) - vim.keymap.set('n', 's', api.node.run.system, opts('Run System')) - vim.keymap.set('n', 'S', api.tree.search_node, opts('Search')) - vim.keymap.set('n', 'U', api.tree.toggle_custom_filter, opts('Toggle Hidden')) - vim.keymap.set('n', 'W', api.tree.collapse_all, opts('Collapse')) - vim.keymap.set('n', 'x', api.fs.cut, opts('Cut')) - vim.keymap.set('n', 'y', api.fs.copy.filename, opts('Copy Name')) - vim.keymap.set('n', 'Y', api.fs.copy.relative_path, opts('Copy Relative Path')) - vim.keymap.set('n', '<2-LeftMouse>', api.node.open.edit, opts('Open')) - vim.keymap.set('n', '<2-RightMouse>', api.tree.change_root_to_node, opts('CD')) - -- END_DEFAULT_ON_ATTACH - - - -- Custom mappings - vim.keymap.set('n', 'l', api.node.open.edit, opts('Open')) - vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Close Directory')) - vim.keymap.set('n', 'cw', api.fs.rename, opts('Rename')) - vim.keymap.set('n', 'o', api.fs.create, opts('Create')) -end - -require'nvim-tree'.setup { - hijack_cursor = true, - on_attach = on_attach, -} - -local function open_on_startup(data) - -- buffer is a [No Name] - local no_name = data.file == "" and vim.bo[data.buf].buftype == "" - - -- buffer is a directory - local directory = vim.fn.isdirectory(data.file) == 1 - - if not no_name and not directory then - return - end - - -- change to the directory - if directory then - vim.cmd.cd(data.file) - end - - -- open the tree - api.tree.open() -end - -vim.api.nvim_set_keymap('n', '<F3>', ':NvimTreeToggle<CR>', { noremap = true, silent = true }) -vim.api.nvim_command('autocmd BufEnter * ++nested if winnr("$") == 1 && bufname() == "NvimTree_" . tabpagenr() | quit | endif') -vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_on_startup }) diff --git a/nvim/.config/nvim/lua/lsp-config.lua b/nvim/.config/nvim/lua/lsp-config.lua deleted file mode 100644 index c08490b..0000000 --- a/nvim/.config/nvim/lua/lsp-config.lua +++ /dev/null @@ -1,154 +0,0 @@ -local nvim_lsp = require('lspconfig') - --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer -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 <c-x><c-o> - 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', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) - buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) - buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) - buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) - buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) - buf_set_keymap('n', 'L', '<cmd>lua vim.diagnostic.open_float()<CR>', opts) - buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) - buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) -end - -local flags = { - debounce_text_changes = 150, -} - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - --- Typescript -nvim_lsp.tsserver.setup { - on_attach = on_attach, - flags = flags, - capabilities = capabilities, - root_dir = nvim_lsp.util.root_pattern("package.json"), -} --- Enhanced features -require('typescript').setup { - server = { - on_attach = on_attach, - }, - flags = flags, - capabilities = capabilities, - disable_commands = false, - go_to_source_definition = { - fallback = true, - }, -} - --- Eslint -nvim_lsp.eslint.setup { - on_attach = on_attach, - flags = flags, - capabilities = capabilities, -} - --- TailwindCSS -nvim_lsp.tailwindcss.setup { - on_attach = on_attach, - flags = flags, - capabilities = capabilities, -} - --- Prisma -nvim_lsp.prismals.setup { - on_attach = on_attach, - flags = flags, - capabilities = capabilities, -} - - --- Vue -nvim_lsp.vuels.setup{ - on_attach = on_attach, - flags = flags, - capabilities = capabilities, -} - --- Rust -nvim_lsp.rust_analyzer.setup{ - on_attach = on_attach, - flags = flags, - capabilities = capabilities, - settings = { - ['rust-analyzer'] = { - checkOnSave = { - allFeatures = true, - overrideCommand = { - 'cargo', 'clippy', '--workspace', '--message-format=json', - '--all-targets', '--all-features'} - } - } - } -} - --- Python -nvim_lsp.pylsp.setup{ - on_attach = on_attach, - flags = flags, - capabilities = capabilities, -} - --- C -nvim_lsp.ccls.setup { - on_attach = on_attach, - flags = flags, - capabilities = capabilities, -} - --- Deno -nvim_lsp.denols.setup { - on_attach = on_attach, - flags = flags, - capabilities = capabilities, - root_dir = nvim_lsp.util.root_pattern("deno.json", "deno.jsonc"), -} - --- Lua -local runtime_path = vim.split(package.path, ';') -table.insert(runtime_path, "lua/?.lua") -table.insert(runtime_path, "lua/?/init.lua") - -nvim_lsp.lua_ls.setup { - on_attach = on_attach, - flags = flags, - capabilities = capabilities, - cmd = { '/usr/bin/lua-language-server' }, -- Install from yay - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = runtime_path, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = {'vim'}, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, -} - diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua deleted file mode 100644 index fbd27c2..0000000 --- a/nvim/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,51 +0,0 @@ -return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - use 'vimwiki/vimwiki' - use 'mhinz/vim-startify' - - -- Lua filetree - use 'kyazdani42/nvim-tree.lua' - - -- Built-in LSP - use 'neovim/nvim-lspconfig' - - -- Autocompletion - use 'hrsh7th/nvim-cmp' - use 'hrsh7th/cmp-buffer' - use 'hrsh7th/cmp-path' - use 'hrsh7th/cmp-nvim-lsp' - use 'hrsh7th/cmp-nvim-lua' - use 'onsails/lspkind-nvim' - - -- Snippets (only used for autocompletion) - use 'L3MON4D3/LuaSnip' - use 'saadparwaiz1/cmp_luasnip' - - -- Treesitter - use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - use 'nvim-treesitter/playground' - - -- Color scheme - use 'sainnhe/gruvbox-material' - - -- Telescope - use 'nvim-lua/plenary.nvim' - use 'nvim-telescope/telescope.nvim' - use 'kyazdani42/nvim-web-devicons' - - -- Misc - use 'christoomey/vim-tmux-navigator' - use 'editorconfig/editorconfig-vim' - use 'ap/vim-css-color' - use 'airblade/vim-gitgutter' - use 'Raimondi/delimitMate' - use 'tonchis/vim-to-github' - - -- Typescript enhanced features - use 'jose-elias-alvarez/typescript.nvim' - - -- Copilot - use 'github/copilot.vim' -end) diff --git a/nvim/.config/nvim/lua/plugins/autoformat.lua b/nvim/.config/nvim/lua/plugins/autoformat.lua new file mode 100644 index 0000000..fb0b510 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/autoformat.lua @@ -0,0 +1,26 @@ +return { + "stevearc/conform.nvim", + lazy = false, + keys = { + { + "<leader>f", + function() + require("conform").format({ async = true, lsp_fallback = true }) + end, + mode = "", + desc = "[F]ormat buffer", + }, + }, + opts = { + notify_on_error = false, + format_on_save = { + timeout_ms = 500, + }, + formatters_by_ft = { + lua = { "stylua" }, + javascript = { { "prettierd", "prettier" } }, -- @fsouza/prettierd + typescript = { { "prettierd", "prettier" } }, + typescriptreact = { { "prettierd", "prettier" } }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua new file mode 100644 index 0000000..3467dbc --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -0,0 +1,69 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + { + "L3MON4D3/LuaSnip", + build = "make install_jsregexp", + dependencies = { + { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + }, + }, + "saadparwaiz1/cmp_luasnip", + + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-nvim-lua", + "onsails/lspkind-nvim", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + luasnip.config.setup({}) + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = "menu,menuone,noinsert" }, + + mapping = cmp.mapping.preset.insert({ + ["<C-n>"] = cmp.mapping.select_next_item(), + ["<C-p>"] = cmp.mapping.select_prev_item(), + ["<C-b>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<CR>"] = cmp.mapping.confirm({ select = true }), + + ["<C-l>"] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { "i", "s" }), + ["<C-h>"] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { "i", "s" }), + }), + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + { name = "buffer", keyword_length = 5 }, + }, + formatting = { + format = require("lspkind").cmp_format({ + with_text = true, + }), + }, + }) + end, +} diff --git a/nvim/.config/nvim/lua/plugins/dadbod.lua b/nvim/.config/nvim/lua/plugins/dadbod.lua new file mode 100644 index 0000000..19311ae --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/dadbod.lua @@ -0,0 +1,17 @@ +return { + "kristijanhusak/vim-dadbod-ui", + dependencies = { + { "tpope/vim-dadbod", lazy = true }, + { "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true }, + }, + cmd = { + "DBUI", + "DBUIToggle", + "DBUIAddConnection", + "DBUIFindBuffer", + }, + init = function() + vim.g.db_ui_use_nerd_fonts = 1 + vim.g.db_ui_env_variable_url = "DATABASE_URL" + end, +} diff --git a/nvim/.config/nvim/lua/plugins/hardtime.lua b/nvim/.config/nvim/lua/plugins/hardtime.lua new file mode 100644 index 0000000..681b96a --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/hardtime.lua @@ -0,0 +1,5 @@ +return { + "m4xshen/hardtime.nvim", + dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" }, + opts = {} +} diff --git a/nvim/.config/nvim/lua/plugins/init.lua b/nvim/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..df23851 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,39 @@ +return { + "sainnhe/gruvbox-material", + { "numToStr/Comment.nvim", opts = {} }, + { -- Adds git related signs to the gutter, as well as utilities for managing changes + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + }, + }, + { + "windwp/nvim-ts-autotag", + init = function() + require("nvim-ts-autotag").setup({ + opts = { + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = false, -- Auto close on trailing </ + }, + }) + end, + }, + { + "windwp/nvim-autopairs", + event = "InsertEnter", + init = function() + require("nvim-autopairs").setup({}) + end, + }, + "christoomey/vim-tmux-navigator", + "ap/vim-css-color", + "tonchis/vim-to-github", + "github/copilot.vim", +} diff --git a/nvim/.config/nvim/lua/plugins/lsp-config.lua b/nvim/.config/nvim/lua/plugins/lsp-config.lua new file mode 100644 index 0000000..ff5b510 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lsp-config.lua @@ -0,0 +1,99 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + { "williamboman/mason.nvim", config = true }, + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + + -- Useful status updates for LSP. + { "j-hui/fidget.nvim", opts = {} }, + + -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + { "folke/neodev.nvim", opts = {} }, + }, + config = function() + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), + callback = function(event) + local map = function(keys, func, desc) + vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) + end + + map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") + map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame") + map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction") + map("K", vim.lsp.buf.hover, "Hover Documentation") + end, + }) + + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) + + -- Add any additional override configuration in the following tables. Available keys are: + -- - cmd (table): Override the default command used to start the server + -- - filetypes (table): Override the default list of associated filetypes for the server + -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. + -- - settings (table): Override the default settings passed when initializing the server. + -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs + -- + -- Some languages (like typescript) have entire language plugins that can be useful: + -- https://github.com/pmizio/typescript-tools.nvim + -- + -- But for many setups, the LSP (`tsserver`) will work just fine + -- tsserver = {}, + -- + + tsserver = {}, + eslint = {}, + tailwindcss = {}, + prismals = {}, + jsonls = {}, + ansiblels = {}, + vuels = {}, + rust_analyzer = {}, + pylsp = {}, + lua_ls = { + -- cmd = {...}, + -- filetypes = { ...}, + -- capabilities = {}, + settings = { + Lua = { + completion = { + callSnippet = "Replace", + }, + -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, + }, + }, + }, + } + + require("mason").setup() + + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + "stylua", -- Used to format Lua code + }) + require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) + + require("mason-lspconfig").setup({ + handlers = { + function(server_name) + local server = servers[server_name] or {} + -- This handles overriding only values explicitly passed + -- by the server configuration above. Useful when disabling + -- certain features of an LSP (for example, turning off formatting for tsserver) + server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) + require("lspconfig")[server_name].setup(server) + end, + }, + }) + end, +} diff --git a/nvim/.config/nvim/lua/plugins/oil.lua b/nvim/.config/nvim/lua/plugins/oil.lua new file mode 100644 index 0000000..6db54db --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/oil.lua @@ -0,0 +1,13 @@ +return { + "stevearc/oil.nvim", + init = function() + require("oil").setup({ + columns = { "icon" }, + view_options = { + show_hidden = true, + }, + }) + + vim.api.nvim_set_keymap("n", "<F3>", ":Oil<CR>", { desc = "Open parent directory" }) + end, +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..d172638 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,76 @@ +return { -- Fuzzy Finder (files, lsp, etc) + "nvim-telescope/telescope.nvim", + event = "VimEnter", + dependencies = { + "nvim-lua/plenary.nvim", + { -- If encountering errors, see telescope-fzf-native README for installation instructions + "nvim-telescope/telescope-fzf-native.nvim", + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = "make", + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable("make") == 1 + end, + }, + { "nvim-telescope/telescope-ui-select.nvim" }, + { "nvim-tree/nvim-web-devicons" }, + }, + config = function() + require("telescope").setup({ + defaults = { + layout_strategy = "vertical", + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown(), + }, + }, + }) + + -- Enable Telescope extensions if they are installed + pcall(require("telescope").load_extension, "fzf") + pcall(require("telescope").load_extension, "ui-select") + + -- See `:help telescope.builtin` + local builtin = require("telescope.builtin") + vim.keymap.set("n", "<leader>ff", function() + builtin.find_files(require("telescope.themes").get_dropdown({ + previewer = false, + find_command = { "rg", "--files", "--iglob", "!.git", "--hidden" }, + })) + end, { desc = "[F]ind [F]iles" }) + vim.keymap.set("n", "<leader>fs", builtin.builtin, { desc = "[F]ind [S]elect Telescope" }) + vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "[F]ind by [G]rep" }) + vim.keymap.set("n", "<leader>fd", builtin.diagnostics, { desc = "[F]ind [D]iagnostics" }) + vim.keymap.set("n", "<leader>fr", builtin.resume, { desc = "[F]ind [R]esume" }) + vim.keymap.set("n", "<leader>f.", builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' }) + vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set("n", "<leader>/", function() + -- You can pass additional configuration to Telescope to change the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ + winblend = 10, + previewer = false, + })) + end, { desc = "[/] Fuzzily search in current buffer" }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set("n", "<leader>f/", function() + builtin.live_grep({ + grep_open_files = true, + prompt_title = "Live Grep in Open Files", + }) + end, { desc = "[F]ind [/] in Open Files" }) + + -- Shortcut for searching your Neovim configuration files + vim.keymap.set("n", "<leader>fn", function() + builtin.find_files({ cwd = vim.fn.stdpath("config") }) + end, { desc = "[F]ind [N]eovim files" }) + end, +} diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..5852a6d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,29 @@ +return { -- Highlight, edit, and navigate code + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + opts = { + ensure_installed = { "bash", "c", "diff", "html", "lua", "luadoc", "markdown", "vim", "vimdoc", "typescript" }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { enable = true }, + }, + config = function(_, opts) + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + + -- Prefer git instead of curl in order to improve connectivity in some environments + require("nvim-treesitter.install").prefer_git = true + ---@diagnostic disable-next-line: missing-fields + require("nvim-treesitter.configs").setup(opts) + + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + end, +} diff --git a/nvim/.config/nvim/lua/plugins/zettelkasten.lua b/nvim/.config/nvim/lua/plugins/zettelkasten.lua new file mode 100644 index 0000000..bbbe0f1 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/zettelkasten.lua @@ -0,0 +1,45 @@ +return { + "mickael-menu/zk-nvim", + init = function() + require("zk").setup({ + picker = "telescope", + + lsp = { + -- `config` is passed to `vim.lsp.start_client(config)` + config = { + cmd = { "zk", "lsp" }, + name = "zk", + on_attach = on_attach, + flags = flags, + capabilities = capabilities, + -- etc, see `:h vim.lsp.start_client()` + }, + + -- automatically attach buffers in a zk notebook that match the given filetypes + auto_attach = { + enabled = true, + filetypes = { "markdown" }, + }, + }, + }) + local opts = { noremap = true, silent = false } + + -- Create a new note after asking for its title. + vim.api.nvim_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>", opts) + + -- Open notes. + vim.api.nvim_set_keymap("n", "<leader>zz", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", opts) + -- Open notes associated with the selected tags. + vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", opts) + + -- Search for the notes matching a given query. + vim.api.nvim_set_keymap( + "n", + "<leader>zf", + "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", + opts + ) + -- Search for the notes matching the current visual selection. + vim.api.nvim_set_keymap("v", "<leader>zf", ":'<,'>ZkMatch<CR>", opts) + end, +} diff --git a/nvim/.config/nvim/lua/treesitter.lua b/nvim/.config/nvim/lua/treesitter.lua deleted file mode 100644 index 7474577..0000000 --- a/nvim/.config/nvim/lua/treesitter.lua +++ /dev/null @@ -1,23 +0,0 @@ -require'nvim-treesitter.configs'.setup { - highlight = { - enable = true, - disable = {}, - }, - indent = { - enable = true, - disable = {}, - }, - ensure_installed = { - "javascript", - "typescript", - "tsx", - "python", - "json", - "yaml", - "html", - "scss" - }, -} - -local parser_config = require "nvim-treesitter.parsers".get_parser_configs() -parser_config.tsx.filetype_to_parsename = { "javascript", "typescript.tsx" } diff --git a/nvim/.config/nvim/startify.vim b/nvim/.config/nvim/startify.vim deleted file mode 100644 index 6361386..0000000 --- a/nvim/.config/nvim/startify.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Startify configuration -let g:startify_session_delete_buffers = 1 -let g:startify_session_persistence = 1 -let g:startify_change_to_vcs_root = 1 -let g:startify_padding_left = 4 - -let g:startify_custom_header = startify#pad(startify#fortune#cowsay('', '═','║','╔','╗','╝','╚')) - -let g:startify_bookmarks = [ - \ { 'z': '~/.dotfiles/env/.zshrc' }, - \ { 'r': '~/.dotfiles/nvim/.config/nvim/init.vim' }, -\ ] - -let g:startify_lists = [ - \ { 'type': 'bookmarks', 'header': [' Bookmarks:'] }, - \ { 'type': 'dir', 'header': [' Recently edited files:'] }, - \ { 'type': 'sessions', 'header': [' Sessions:'] }, -\] - -autocmd VimEnter * - \ if !argc() - \ | Startify - \ | wincmd w - \ | endif diff --git a/nvim/.config/nvim/vimwiki.vim b/nvim/.config/nvim/vimwiki.vim deleted file mode 100644 index ab3696d..0000000 --- a/nvim/.config/nvim/vimwiki.vim +++ /dev/null @@ -1,29 +0,0 @@ -" Vimwiki configuration -let g:vimwiki_list = [ - \ {'path': '~/Sync/', 'syntax': 'markdown', 'ext': '.md', 'auto_generate_links': 1}, - \ {'path': '~/Documents/Projects/eug-vs-xyz', 'syntax': 'markdown', 'ext': '.md', 'auto_generate_links': 1, 'diary_rel_path': 'blog/', 'diary_index': 'index', 'diary_header': "Blog"}, - \ {'path': '~/Documents/wiki/', 'syntax': 'markdown', 'ext': '.md'}, -\] - -let g:vimwiki_markdown_link_ext = 1 - -autocmd FileType vimwiki,tex setlocal spell wrap linebreak - -nnoremap <Leader>c :let &cole=(&cole == 2) ? 0 : 2 <bar> echo 'conceallevel ' . &cole <CR> - -function! VimwikiLinkHandler(link) - let link = a:link - if link =~# '^vfile:' - let link = link[1:] - else - return 0 - endif - let link_infos = vimwiki#base#resolve_link(link) - if link_infos.filename == '' - echomsg 'Vimwiki Error: Unable to resolve link!' - return 0 - else - exe 'e ' . fnameescape(link_infos.filename) - return 1 - endif -endfunction |