return cmds as a module

This commit is contained in:
2022-02-02 21:31:31 +03:00
parent fa176e51af
commit d9e217383e
2 changed files with 9 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
local yank = require("user.utils").yank local yank = require("user.utils").yank
function open_terminal(vertically) local M = {}
M.open_terminal = function(vertically)
vertically = vertically or false vertically = vertically or false
if vertically then if vertically then
@@ -10,7 +12,7 @@ function open_terminal(vertically)
end end
end end
function copy_diagnostic_message() M.copy_diagnostic_message = function()
local diagnostics = vim.lsp.diagnostic.get_line_diagnostics() local diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
if #diagnostics == 0 then if #diagnostics == 0 then
@@ -26,3 +28,5 @@ function copy_diagnostic_message()
print("Diagnostic message was yanked") print("Diagnostic message was yanked")
end end
return M

View File

@@ -31,8 +31,8 @@ vmap(">", ">gv")
-- Terminal -- Terminal
tmap("<ESC>", "<C-\\><C-n>") -- Escape - in terminal mode, quit to normal mode tmap("<ESC>", "<C-\\><C-n>") -- Escape - in terminal mode, quit to normal mode
nmap("Th", ":lua open_terminal()<CR>") -- Shift+t - open terminal in horizontal split nmap("Th", ":lua require('user.cmds').open_terminal()<CR>") -- Shift+t - open terminal in horizontal split
nmap("Tv", ":lua open_terminal(true)<CR>") -- Shift+t+v - open terminal in vertical split nmap("Tv", ":lua require('user.cmds').open_terminal(true)<CR>") -- Shift+t+v - open terminal in vertical split
-- Tabs -- Tabs
nmap("H", ":tabprev<CR>") -- Shift+h - open previous tab nmap("H", ":tabprev<CR>") -- Shift+h - open previous tab
@@ -55,7 +55,7 @@ nmap("<F2>", ":lua vim.lsp.buf.rename()<CR>") -- F2 - Rename thing under the cur
nmap("<leader>.", ":lua vim.lsp.buf.code_action()<CR>") -- Leader+. - show code actions to run nmap("<leader>.", ":lua vim.lsp.buf.code_action()<CR>") -- Leader+. - show code actions to run
vmap("<leader>.", ":lua vim.lsp.buf.range_code_action()<CR>") -- same as above but for visual mode vmap("<leader>.", ":lua vim.lsp.buf.range_code_action()<CR>") -- same as above but for visual mode
nmap("<leader>dd", ':lua vim.diagnostic.open_float(nil, {focus = false, scope = "cursor"})<CR>') -- Leader+d - show diagnostics in float window nmap("<leader>dd", ':lua vim.diagnostic.open_float(nil, {focus = false, scope = "cursor"})<CR>') -- Leader+d - show diagnostics in float window
nmap("<leader>dy", ":lua copy_diagnostic_message()<CR>") -- Leader+d+c - copy diagnostic message nmap("<leader>dy", ":lua require('user.cmds').copy_diagnostic_message()<CR>") -- Leader+d+c - copy diagnostic message
-- Git -- Git
nmap("<leader>gg", ":G<CR>") -- Leader+g+g - open vim-fugitive window nmap("<leader>gg", ":G<CR>") -- Leader+g+g - open vim-fugitive window