Created
March 27, 2024 18:29
-
-
Save agnesjang98/b1aeda42d45ee63ab803a3b2e0f44714 to your computer and use it in GitHub Desktop.
Error executing vim.schedule lua callback: vim/keymap.lua:0: rhs: expected string|function, got nil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error executing vim.schedule lua callback: vim/keymap.lua:0: rhs: expected string|function, got nil | |
stack traceback: | |
[C]: in function 'error' | |
vim/shared.lua: in function 'validate' | |
vim/keymap.lua: in function 'set' | |
/Users/agnes.jang/.config/nvim/lua/language.lua:79: in function '_on_attach' | |
...re/nvim/plugged/nvim-lspconfig/lua/lspconfig/configs.lua:292: in function '_setup_buffer' | |
...re/nvim/plugged/nvim-lspconfig/lua/lspconfig/configs.lua:195: in function '' | |
vim/_editor.lua: in function <vim/_editor.lua:0> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Install VimPlug if not present | |
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) | |
!curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall | |
endif | |
call plug#begin() | |
" The default plugin directory will be as follows: | |
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged' | |
" - e.g. `call plug#begin('~/.vim/plugged')` | |
" - Avoid using standard Vim directory names like 'plugin' | |
Plug 'catppuccin/nvim', {'as': 'catppuccin'} | |
Plug 'tpope/vim-commentary' | |
Plug 'ms-jpq/chadtree', {'branch': 'chad', 'do': 'python3 -m chadtree deps'} | |
" Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'nvim-lualine/lualine.nvim' | |
Plug 'kyazdani42/nvim-web-devicons' | |
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} | |
Plug 'nvim-lua/plenary.nvim' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'tmsvg/pear-tree' | |
" Plug 'sbdchd/neoformat' | |
" Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' } | |
Plug 'neovim/nvim-lspconfig' | |
Plug 'hrsh7th/cmp-nvim-lsp' | |
Plug 'hrsh7th/cmp-buffer' | |
Plug 'hrsh7th/cmp-path' | |
Plug 'hrsh7th/cmp-cmdline' | |
Plug 'hrsh7th/nvim-cmp' | |
Plug 'SirVer/ultisnips' | |
Plug 'quangnguyen30192/cmp-nvim-ultisnips' | |
Plug 'simrat39/rust-tools.nvim' | |
Plug 'sheerun/vim-polyglot' | |
" Plug 'ruifm/gitlinker.nvim' | |
" Vim Script | |
Plug 'nvim-tree/nvim-web-devicons' | |
Plug 'folke/trouble.nvim' | |
" Initialize plugin system | |
call plug#end() | |
set clipboard+=unnamedplus | |
set laststatus=2 | |
set softtabstop=4 | |
set shiftwidth=4 | |
set tabstop=4 | |
set expandtab | |
set autoindent | |
set copyindent | |
set formatoptions-=cro " Don't continue comments and quotes on next line | |
set number relativenumber | |
set cursorline | |
set splitright | |
set splitbelow | |
set statusline+=%F | |
lua require("init") | |
" Set leader to space | |
let mapleader = " " | |
" Chad tree stuff | |
nnoremap <leader>n <cmd>CHADopen<cr> | |
nnoremap <leader>N <cmd>CHADopen --always-focus<cr> | |
nnoremap <leader>xx <cmd>TroubleToggle<cr> | |
nnoremap <leader>xw <cmd>TroubleToggle workspace_diagnostics<cr> | |
nnoremap <leader>xd <cmd>TroubleToggle document_diagnostics<cr> | |
nnoremap <leader>xq <cmd>TroubleToggle quickfix<cr> | |
nnoremap <leader>xl <cmd>TroubleToggle loclist<cr> | |
nnoremap gR <cmd>TroubleToggle lsp_references<cr> | |
nnoremap <silent> g? <cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR> | |
augroup fmt | |
autocmd! | |
autocmd BufWritePre * undojoin | Neoformat | |
augroup END | |
let g:chadtree_settings = { "theme": { "icon_colour_set": "none" } } | |
execute pathogen#infect() | |
autocmd BufReadPre * | |
\ let f=getfsize(expand("<afile>")) | |
\ | if f > 100000 || f == -2 | |
\ | let b:copilot_enabled = v:false | |
\ | endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Make line numbers default | |
vim.wo.number = true | |
--Enable break indent | |
vim.o.breakindent = true | |
--Save undo history | |
vim.opt.undofile = true | |
--Case insensitive searching UNLESS /C or capital in search | |
vim.o.ignorecase = true | |
vim.o.smartcase = true | |
--Remap space as leader key | |
vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { noremap = true, silent = true }) | |
vim.g.mapleader = ' ' | |
vim.g.maplocalleader = ' ' | |
-- Highlight on yank | |
vim.cmd [[ | |
augroup YankHighlight | |
autocmd! | |
autocmd TextYankPost * silent! lua vim.highlight.on_yank() | |
augroup end | |
]] | |
-- Treesitter | |
require'nvim-treesitter.configs'.setup { | |
-- A list of parser names, or "all" | |
ensure_installed = { "c", "lua", "go", "rust", "python", "m68k" }, | |
-- Install parsers synchronously (only applied to `ensure_installed`) | |
sync_install = false, | |
highlight = { | |
-- `false` will disable the whole extension | |
enable = true, | |
-- 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, | |
}, | |
} | |
local opts = { noremap=true, silent=true } | |
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts) | |
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) | |
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) | |
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts) | |
-- 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) | |
-- Enable completion triggered by <c-x><c-o> | |
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') | |
-- Mappings. | |
-- See `:help vim.lsp.*` for documentation on any of the below functions | |
local bufopts = { noremap=true, silent=true, buffer=bufnr } | |
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) | |
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) | |
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) | |
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) | |
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) | |
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts) | |
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts) | |
vim.keymap.set('n', '<space>wl', function() | |
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) | |
end, bufopts) | |
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts) | |
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) | |
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts) | |
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) | |
vim.keymap.set('n', '<leader>f', vim.lsp.buf.formatting, bufopts) | |
end | |
local lsp_flags = { | |
-- This is the default in Nvim 0.7+ | |
debounce_text_changes = 150, | |
} | |
-- completion | |
local cmp = require'cmp' | |
cmp.setup({ | |
snippet = { | |
-- REQUIRED - you must specify a snippet engine | |
expand = function(args) | |
vim.fn["UltiSnips#anonymous"](args.body) -- For `vsnip` users. | |
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. | |
-- require('snippy').expand_snippet(args.body) -- For `snippy` users. | |
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. | |
end, | |
}, | |
window = { | |
-- completion = cmp.config.window.bordered(), | |
-- documentation = cmp.config.window.bordered(), | |
}, | |
mapping = cmp.mapping.preset.insert({ | |
['<C-e>'] = cmp.mapping.abort(), | |
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | |
["<Tab>"] = cmp.mapping(function(fallback) | |
if cmp.visible() then | |
cmp.select_next_item() | |
else | |
fallback() | |
end | |
end, { "i" }), | |
["<S-Tab>"] = cmp.mapping(function(fallback) | |
if cmp.visible() then | |
cmp.select_prev_item() | |
else | |
fallback() | |
end | |
end, { "i" }), | |
}), | |
sources = cmp.config.sources({ | |
{ name = 'nvim_lsp' }, | |
-- { name = 'vsnip' }, -- For vsnip users. | |
-- { name = 'luasnip' }, -- For luasnip users. | |
{ name = 'ultisnips' }, -- For ultisnips users. | |
-- { name = 'snippy' }, -- For snippy users. | |
}, { | |
{ name = 'buffer' }, | |
}) | |
}) | |
-- Set configuration for specific filetype. | |
cmp.setup.filetype('gitcommit', { | |
sources = cmp.config.sources({ | |
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. | |
}, { | |
{ name = 'buffer' }, | |
}) | |
}) | |
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). | |
cmp.setup.cmdline('/', { | |
mapping = cmp.mapping.preset.cmdline(), | |
sources = { | |
{ name = 'buffer' } | |
} | |
}) | |
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). | |
cmp.setup.cmdline(':', { | |
mapping = cmp.mapping.preset.cmdline(), | |
sources = cmp.config.sources({ | |
{ name = 'path' } | |
}, { | |
{ name = 'cmdline' } | |
}) | |
}) | |
-- Setup lspconfig. | |
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) | |
local lspconfig = require('lspconfig') | |
local servers = { 'gopls', 'pyright' } | |
for _, lsp in ipairs(servers) do | |
lspconfig[lsp].setup { | |
on_attach = on_attach, | |
flags = lsp_flags, | |
capabilities = capabilities, | |
} | |
end | |
local rt = require("rust-tools") | |
rt.setup({ | |
server = { | |
on_attach = function(client, bufnr) | |
on_attach(client, bufnr) | |
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr }) | |
-- Code action groups | |
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr }) | |
end, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment