init.lua (2671B)
1 vim.cmd([[ 2 set runtimepath^=~/.vim runtimepath+=~/.vim/after 3 let &packpath = &runtimepath 4 call setenv("MYOLDVIMRC", "~/.vim/vimrc") 5 source $MYOLDVIMRC 6 ]]) 7 8 -- Install Lazy 9 local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" 10 if not vim.uv.fs_stat(lazypath) then 11 vim.fn.system({ 12 "git", 13 "clone", 14 "--filter=blob:none", 15 "https://github.com/folke/lazy.nvim.git", 16 "--branch=stable", -- latest stable release 17 lazypath, 18 }) 19 end 20 21 vim.opt.rtp:prepend(lazypath) 22 23 require('lazy').setup('plugins', { 24 performance = { 25 rtp = { 26 reset = false, 27 }, 28 }, 29 }) 30 31 -- Set completeopt to have a better completion experience 32 vim.o.completeopt = 'menuone,noselect' 33 34 -- [[ Basic Keymaps ]] 35 -- Set <space> as the leader key 36 -- See `:help mapleader` 37 -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) 38 vim.g.mapleader = ' ' 39 40 -- Keymaps for better default experience 41 -- See `:help vim.keymap.set()` 42 vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) 43 44 -- [[ Highlight on yank ]] 45 -- See `:help vim.highlight.on_yank()` 46 local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) 47 vim.api.nvim_create_autocmd('TextYankPost', { 48 callback = function() 49 vim.highlight.on_yank() 50 end, 51 group = highlight_group, 52 pattern = '*', 53 }) 54 55 56 -- Diagnostic keymaps 57 vim.keymap.set('n', '[d', function() vim.diagnostic.jump({ count = -1, float = true }) end) 58 vim.keymap.set('n', ']d', function() vim.diagnostic.jump({ count = 1, float = true }) end) 59 vim.keymap.set('n', ']e', function() vim.diagnostic.jump({ count = 1, float = true, severity = vim.diagnostic.severity.ERROR }) end) 60 vim.keymap.set('n', '[e', function() vim.diagnostic.jump({ count = -1, float = true, severity = vim.diagnostic.severity.ERROR }) end) 61 vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float) 62 vim.keymap.set('n', '<leader>q', function() vim.diagnostic.setloclist({ severity = vim.diagnostic.severity.ERROR }) end) 63 64 -- 'i' that indents correctly on empty lines 65 vim.keymap.set('n', 'i', function() 66 if #vim.fn.getline(".") == 0 then 67 return [["_cc]] 68 else 69 return "i" 70 end 71 end, {expr = true}) 72 73 require('llm') 74 75 vim.cmd ([[ 76 nnoremap <leader><C-e><C-u> :<c-u>exe "vsplit ~/.vim/snippets/"..&filetype..".snippets"<CR> 77 ]]) 78 79 vim.api.nvim_create_autocmd('LspAttach', { 80 group = vim.api.nvim_create_augroup('UserLspConfig', {}), 81 callback = function(ev) 82 local client = vim.lsp.get_client_by_id(ev.data.client_id) 83 if client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then 84 vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf }) 85 end 86 end, 87 })