diff --git a/ftplugin/java.lua b/ftplugin/java.lua index fafb9ee..302b44f 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -251,3 +251,46 @@ keymap('n', 'ju', 'JdtUpdateConfig', opts) keymap('v', 'jv', "lua require('jdtls').extract_variable(true)", opts) keymap('v', 'jc', "lua require('jdtls').extract_constant(true)", opts) keymap('v', 'jm', "lua require('jdtls').extract_method(true)", opts) + +local wk = require 'which-key' +local optsj = { + mode = 'n', -- NORMAL mode + prefix = '', + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local vopts = { + mode = 'v', -- VISUAL mode + prefix = '', + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local mappingsj = { + L = { + name = 'Java', + o = { "lua require'jdtls'.organize_imports()", 'Organize Imports' }, + v = { "lua require('jdtls').extract_variable()", 'Extract Variable' }, + c = { "lua require('jdtls').extract_constant()", 'Extract Constant' }, + t = { "lua require'jdtls'.test_nearest_method()", 'Test Method' }, + T = { "lua require'jdtls'.test_class()", 'Test Class' }, + u = { 'JdtUpdateConfig', 'Update Config' }, + }, +} + +local vmappings = { + L = { + name = 'Java', + v = { "lua require('jdtls').extract_variable(true)", 'Extract Variable' }, + c = { "lua require('jdtls').extract_constant(true)", 'Extract Constant' }, + m = { "lua require('jdtls').extract_method(true)", 'Extract Method' }, + }, +} + +wk.register(mappingsj, optsj) +wk.register(vmappings, vopts) diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua index d9e9061..5acce7b 100644 --- a/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -86,13 +86,13 @@ function UnMapDHM() vim.api.nvim_del_keymap('n', 'N') end --- local handle = io.popen 'lsusb | grep -c Sofle' --- local automap = handle:read '*n' --- handle:close() +local handle = io.popen 'lsusb | grep -c Sofle' +local automap = handle:read '*n' +handle:close() --- if automap or os.getenv("SSH_TTY") then -MapDHM() --- end +if not automap or os.getenv 'SSH_TTY' then + MapDHM() +end local wk = require 'which-key' @@ -220,45 +220,3 @@ local mappings = { } -- }}} wk.register(mappings, opts) - -local optsj = { - mode = "n", -- NORMAL mode - prefix = "", - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps -} - -local vopts = { - mode = "v", -- VISUAL mode - prefix = "", - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps -} - -local mappingsj = { - L = { - name = "Java", - o = { "lua require'jdtls'.organize_imports()", "Organize Imports" }, - v = { "lua require('jdtls').extract_variable()", "Extract Variable" }, - c = { "lua require('jdtls').extract_constant()", "Extract Constant" }, - t = { "lua require'jdtls'.test_nearest_method()", "Test Method" }, - T = { "lua require'jdtls'.test_class()", "Test Class" }, - u = { "JdtUpdateConfig", "Update Config" }, - }, -} - -local vmappings = { - L = { - name = "Java", - v = { "lua require('jdtls').extract_variable(true)", "Extract Variable" }, - c = { "lua require('jdtls').extract_constant(true)", "Extract Constant" }, - m = { "lua require('jdtls').extract_method(true)", "Extract Method" }, - }, -} - -wk.register(mappingsj, optsj) -wk.register(vmappings, vopts)