dotfiles

Cross platform dotfiles for linux, mac and windows
git clone git@getsh.org:dotfiles.git
Log | Files | Refs

keybindings.lua (2432B)


      1 local map = vim.keymap.set
      2 
      3 vim.cmd[[source $XDG_DATA_HOME/vim/keybindings.vim]]
      4 
      5 vim.api.nvim_create_autocmd('LspAttach', {
      6   callback = function(args)
      7   -- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
      8 
      9   local lspbuf = vim.lsp.buf
     10   local bufopts = { noremap=true, buffer=args.buf }
     11   map({'n', 'v'}, '<a-CR>', lspbuf.code_action, bufopts)
     12   map('n', 'gD', lspbuf.declaration, bufopts)
     13   map('n', 'gd', lspbuf.definition, bufopts)
     14   map('n', 'K', lspbuf.hover, bufopts)
     15   map('n', 'gi', lspbuf.implementation, bufopts)
     16   map('n', '<space>D', lspbuf.type_definition, bufopts)
     17   map('n', '<space>rn', lspbuf.rename, bufopts)
     18   map('n', '<space>ca', lspbuf.code_action, bufopts)
     19   map('n', 'gr', lspbuf.references, bufopts)
     20   map('n', '<space>f', function() lspbuf.format { async = true } end, bufopts)
     21   end
     22 })
     23 
     24 function file_mv_helper()
     25 	vim.cmd('normal! 0i"A"0y$A p0imv j0')
     26 end
     27 
     28 -- general
     29 map("n", "<leader>ec", ":edit $XDG_CONFIG_HOME/nvim/init.lua<cr>")
     30 map("n", "<leader>sc", ":source $XDG_CONFIG_HOME/nvim/init.lua<cr>")
     31 
     32 -- nvim-dap
     33 map("n", "<leader>dd", ":lua require'dap'.continue()<cr>")
     34 map("n", "<leader>de", ":lua require'dap'.terminate()<cr> | :lua require'dap'.close()<cr>")
     35 map("n", "<leader>dl", ":lua require'dap'.step_into()<cr>")
     36 map("n", "<leader>dj", ":lua require'dap'.step_over()<cr>")
     37 map("n", "<leader>dk", ":lua require'dap'.step_out()<cr>")
     38 map("n", "<leader>dr", ":lua require'dap'.restart()<cr>")
     39 
     40 -- nvim-dap-ui
     41 map("n", "<leader>du", ":lua require'dapui'.toggle()<cr>")
     42 
     43 map("n", "<leader>drc", ":lua require'dap'.RunToCursor()")
     44 map("n", "<leader>db" , ":lua require'dap'.toggle_breakpoint()<cr>")
     45 map("n", "<leader>dcb", ":lua require'dap'.ToggleConditionalBreakpoint()")
     46 
     47 -- map("n", "<leader>dc", ":call GotoWindow(require'dap'.session_windows.code)<CR>")
     48 -- map("n", "<leader>dt", ":call GotoWindow(require'dap'.session_windows.tagpage)<CR>")
     49 -- map("n", "<leader>dv", ":call GotoWindow(require'dap'.session_windows.variables)<CR>")
     50 -- map("n", "<leader>dw", ":call GotoWindow(require'dap'.session_windows.watches)<CR>")
     51 -- map("n", "<leader>ds", ":call GotoWindow(require'dap'.session_windows.stack_trace)<CR>")
     52 -- map("n", "<leader>do", ":call GotoWindow(require'dap'.session_windows.output)<CR>")
     53 -- map("n", "<leader>dtcb", ":call vimspector#CleanLineBreakpoint()<CR>")
     54 
     55 -- neovim diagnostics
     56 map("n", "<leader>sd", ":lua vim.diagnostic.open_float()<cr>")