local cmd = vim.cmd local map = vim.api.nvim_set_keymap local M = {} -- map the leader key map('n', '', '', {}) vim.g.mapleader = ' ' options = { noremap = true } map('n', '', ':nohlsearch', options) map('n', 'n', ':bnext', options) map('n', 'p', ':bprev', options) -- Not an editor command: Wqa cmd(':command! WQ wq') cmd(':command! WQ wq') cmd(':command! Wq wq') cmd(':command! Wqa wqa') cmd(':command! W w') cmd(':command! Q q') local function fzy_ignore(patterns) pattern_cmd = {} for _, p in ipairs(patterns) do table.insert(pattern_cmd, string.format("! -path '%s'", p)) end return table.concat(pattern_cmd, ' ') end -- fzy mappings if vim.fn.executable('fzy') then _G.fzy_shell_cmd = require('fzy.shell').fzy_shell_cmd map( '', 'e', string.format( ':call v:lua.fzy_shell_cmd("find -L . -type f %s", ":e")', fzy_ignore{'*.git/*', '*node_modules*', '*.pyc', '*migrations*'} ), { noremap=true, silent=true } ) _G.fzy_buffers = require('fzy.buffers').fzy_buffers map('', 'b', ':call v:lua.fzy_buffers()', { noremap=true, silent=true } ) _G.fzy_jmp = require('fzy.jump').fzy_jmp map('', 'f', ':call v:lua.fzy_jmp()', { noremap=true, silent=true} ) else print('fzy not in PATH!') end -- lspconfig function M.on_attach(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 buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', options) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', options) end -- completion-nvim -- FIXME: rewrite this in Lua vim.api.nvim_exec([[ " Use and to navigate through popup menu inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " Set completeopt to have a better completion experience set completeopt=menuone,noinsert,noselect " Avoid showing message extra message when using completion set shortmess+=c ]], false) -- complete from buffer vim.api.nvim_exec([[ inoremap getline('.')[col('.') - 2] =~ '\w' ? "" : "" ]], false) return M