diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-02-12 16:55:13 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-02-12 16:55:13 +0200 |
| commit | d69abfcf20866c4f8b275676cdcca605c53e02b1 (patch) | |
| tree | 727e8218d2900775959fce0add3be410f34d1ba9 /.config | |
| parent | 009cd3c349ada787d5828d69655c7cd78707ae40 (diff) | |
| parent | b10c2f1a3c45abf96194d73d5d546eef225dc06d (diff) | |
| download | dotfiles-d69abfcf20866c4f8b275676cdcca605c53e02b1.tar.gz dotfiles-d69abfcf20866c4f8b275676cdcca605c53e02b1.zip | |
Merge commit 'fb5d4420ee71f53c5550cf9217b54355d202c1a0'
Diffstat (limited to '.config')
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 4 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/toggleterm.lua | 71 | ||||
| -rw-r--r-- | .config/nvim/lua/user/keys.lua | 3 | ||||
| -rw-r--r-- | .config/nvim/lua/user/utils.lua | 14 |
4 files changed, 76 insertions, 16 deletions
diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 2d3944a..548df74 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -11,7 +11,7 @@ require('mason').setup() require("mason-lspconfig").setup({ ensure_installed = { "clangd", - "sumneko_lua", + "lua_ls", "pylsp", "pyright", }, @@ -223,7 +223,7 @@ if utils.executable("bash-language-server") then end if utils.executable("lua-language-server") then - lspconfig.sumneko_lua.setup({ + lspconfig.lua_ls.setup({ on_attach = on_attach, settings = { Lua = { diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua index 0c3c45f..024c2f6 100644 --- a/.config/nvim/lua/plugins/toggleterm.lua +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -4,13 +4,13 @@ if not status_ok then end toggleterm.setup({ - size = function(term) - if term.direction == "horizontal" then - return 12 - elseif term.direction == "vertical" then - return vim.o.columns * 0.3 - end - end, + --size = function(term) + -- if term.direction == "horizontal" then + -- return 12 + -- elseif term.direction == "vertical" then + -- return vim.o.columns * 0.3 + -- end + --end, --size = 20, open_mapping = [[<leader>tt]], hide_numbers = true, @@ -31,7 +31,18 @@ toggleterm.setup({ Normal = { background = "#000000", }, - }, + --float_opts = { + -- border = as.style.current.border, + -- winblend = 3, + --}, + size = function(term) + if term.direction == 'horizontal' then + return 15 + elseif term.direction == 'vertical' then + return math.floor(vim.o.columns * 0.4) + end + end, + }, float_opts = { width = 70, height = 15, @@ -44,6 +55,14 @@ toggleterm.setup({ }, }, }) +local utils = require("user.utils") +local float_handler = function(term) + + if not utils.empty(vim.fn.mapcheck('jj', 't')) then + vim.keymap.del('t', 'jj', { buffer = term.bufnr }) + vim.keymap.del('t', '<esc>', { buffer = term.bufnr }) + end +end function _G.set_terminal_keymaps() local opts = { noremap = true } @@ -56,13 +75,40 @@ function _G.set_terminal_keymaps() vim.api.nvim_buf_set_keymap(0, "t", "<C-l>", [[<C-\><C-n><C-W>l]], opts) end -vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") +-- if you only want these mappings for toggle term use term://*toggleterm#* instead +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') +--vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()") local Terminal = require("toggleterm.terminal").Terminal -local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) +local lazygit = Terminal:new({ + cmd = "lazygit", + count = 5, + dir = "git_dir", + direction = "float", + on_open = float_handler, + hidden = true, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + width = 150, + height = 40 + }, + ---- Function to run on opening the terminal + --on_open = function(term) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<esc>', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<C-\\>', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + --end, + ---- Function to run on closing the terminal + --on_close = function(term) + -- vim.cmd("startinsert!") + --end +}) -function _LAZYGIT_TOGGLE() - lazygit:toggle() +function Lazygit_toggle() + lazygit:toggle() end local node = Terminal:new({ cmd = "node", hidden = true }) @@ -88,3 +134,4 @@ local python = Terminal:new({ cmd = "python", hidden = true }) function _PYTHON_TOGGLE() python:toggle() end + diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua index d92b642..4556510 100644 --- a/.config/nvim/lua/user/keys.lua +++ b/.config/nvim/lua/user/keys.lua @@ -216,7 +216,7 @@ map('n', '<C-j>', '<CMD>NavigatorDown<CR>') --map("n", "<leader>tt", "<cmd>ToggleTerm<cr>") -- LazyGit -map("n", "<leader>gg", ":LazyGit<CR>") +map({"n", "t"}, "<leader>gg", "<cmd>lua Lazygit_toggle()<CR>") -- Fugitive git bindings map("n", "<leader>ga", ":Git add %:p<CR><CR>") @@ -237,7 +237,6 @@ map("n", "<leader>gm", ":Gmove<Space>") --map("n", "<leader>gps", ":Dispatch! git push<CR>") --map("n", "<leader>gpl", ":Dispatch! git pull<CR>") -- map["<C-\\>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" } --- map["<leader>gg"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } -- map["<leader>tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } -- map["<leader>tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } -- map["<leader>tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } diff --git a/.config/nvim/lua/user/utils.lua b/.config/nvim/lua/user/utils.lua index 07867a4..f70fac5 100644 --- a/.config/nvim/lua/user/utils.lua +++ b/.config/nvim/lua/user/utils.lua @@ -28,6 +28,20 @@ end -------------------------------------------------- +---Determine if a value of any type is empty +---@param item any +---@return boolean? +function M.empty(item) + if not item then return true end + local item_type = type(item) + if item_type == 'string' then return item == '' end + if item_type == 'number' then return item <= 0 end + if item_type == 'table' then return vim.tbl_isempty(item) end + return item ~= nil +end + +-------------------------------------------------- + --- Create a dir if it does not exist function M.may_create_dir(dir) local res = fn.isdirectory(dir) |
