From f1d2764a79a10e6a7e1ab000a1d5629d6cd3c3cc Mon Sep 17 00:00:00 2001 From: Tyler Starr Date: Mon, 13 Feb 2023 21:22:54 -0800 Subject: [PATCH] updates to nvim --- home/dot_config/i3/config.tmpl | 3 +- .../i3/scripts/executable_autolayout.sh | 25 ++++++ home/dot_config/nvim/after/plugin/lsp.lua | 1 + home/dot_config/nvim/lua/tstarr/init.lua | 1 + home/dot_config/nvim/lua/tstarr/iron.lua | 88 +++++++++++++++++++ home/dot_config/nvim/lua/tstarr/packer.lua | 1 + 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 home/dot_config/i3/scripts/executable_autolayout.sh create mode 100644 home/dot_config/nvim/lua/tstarr/iron.lua diff --git a/home/dot_config/i3/config.tmpl b/home/dot_config/i3/config.tmpl index d7f8ba0a..8f9c0835 100644 --- a/home/dot_config/i3/config.tmpl +++ b/home/dot_config/i3/config.tmpl @@ -184,7 +184,7 @@ bindsym $mod+Shift+r move container to workspace $tag8 # audio bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 0 +2% bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -2% -bindsym XF86AudioMute exec amixer -q set Master toggle +bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle # [o]pen applications bindsym $mod+Return exec alacritty @@ -217,6 +217,7 @@ mode scratch { exec --no-startup-id "autorandr --change && i3-msg restart" exec --no-startup-id "pipewire & pipewire-pulse &" exec --no-startup-id "udiskie &" +exec_always --no-startup-id "$HOME/.config/i3/scripts/autolayout.sh" exec_always --no-startup-id "$HOME/.config/i3/scripts/polybar.sh" exec_always --no-startup-id "blueman-applet" exec_always --no-startup-id "nm-applet" diff --git a/home/dot_config/i3/scripts/executable_autolayout.sh b/home/dot_config/i3/scripts/executable_autolayout.sh new file mode 100644 index 00000000..061e8e01 --- /dev/null +++ b/home/dot_config/i3/scripts/executable_autolayout.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import i3ipc + +i3 = i3ipc.Connection() + +def on_window_event(i3, e): + focused_container = i3.get_tree().find_focused().parent + # Get parent layout of focused window + parent_layout = focused_container.layout + # Get number of windows in focues container + num_parent_windows = len(focused_container.nodes) + # Get number of windows in workspace + workspace = i3.get_tree().find_focused().workspace() + num_workspace_windows = len(workspace.leaves()) + if num_parent_windows > 1 and parent_layout != "tabbed": + i3.command("splitv; layout tabbed") + elif num_workspace_windows == 1: + i3.command("layout splith") + +# Subscribe to window events +i3.on("window", on_window_event) + +# Start the main loop +i3.main() diff --git a/home/dot_config/nvim/after/plugin/lsp.lua b/home/dot_config/nvim/after/plugin/lsp.lua index 287380fa..334b4c69 100644 --- a/home/dot_config/nvim/after/plugin/lsp.lua +++ b/home/dot_config/nvim/after/plugin/lsp.lua @@ -104,3 +104,4 @@ local function config(_config) end require("lspconfig").tsserver.setup(config()) +require'lspconfig'.pyright.setup(config()) diff --git a/home/dot_config/nvim/lua/tstarr/init.lua b/home/dot_config/nvim/lua/tstarr/init.lua index 139790ab..dec09f2e 100644 --- a/home/dot_config/nvim/lua/tstarr/init.lua +++ b/home/dot_config/nvim/lua/tstarr/init.lua @@ -3,3 +3,4 @@ require("tstarr.packer") require("tstarr.telescope") require("tstarr.vimwiki") require("tstarr.which-key") +require("tstarr.iron") diff --git a/home/dot_config/nvim/lua/tstarr/iron.lua b/home/dot_config/nvim/lua/tstarr/iron.lua new file mode 100644 index 00000000..102674e9 --- /dev/null +++ b/home/dot_config/nvim/lua/tstarr/iron.lua @@ -0,0 +1,88 @@ +local iron = require("iron.core") +local wk = require("which-key") + +iron.setup { + config = { + -- Whether a repl should be discarded or not + scratch_repl = true, + -- Your repl definitions come here + repl_definition = { + sh = { + -- Can be a table or a function that + -- returns a table (see below) + command = {"zsh"} + }, + python = require("iron.fts.python").ipython + }, + -- How the repl window will be displayed + -- See below for more information + repl_open_cmd = require('iron.view').right("35%"), + }, + -- Iron doesn't set keymaps by default anymore. + -- You can set them here or manually add keymaps to the functions in iron.core + keymaps = { + send_motion = "rm", + visual_send = "rv", + send_file = "rf", + send_line = "rl", + send_mark = "rms", + mark_motion = "rmm", + mark_visual = "rmv", + remove_mark = "rmm", + cr = "r", + interrupt = "r", + exit = "rq", + clear = "rc", + }, + -- If the highlight is on, you can change how it looks + -- For the available options, check nvim_set_hl + highlight = { + italic = true + }, + ignore_blank_lines = true, -- ignore blank lines when sending visual select lines +} + +-- Iron also has a list of commands, see :h iron-commands for all available commands +vim.keymap.set('n', 'rs', 'IronRepl') +vim.keymap.set('n', 'rr', 'IronRestart') +vim.keymap.set('n', 'rh', 'IronHide') + +-- Define the function to exit terminal mode +local function exit_terminal_mode() + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, false, true), 'n', true) +end + +-- Map the Escape key to the exit_terminal_mode function in terminal mode +vim.keymap.set('t', '', function () exit_terminal_mode() end, {noremap = true}) + +wk.register({ + r = { + name = "+iron", + m = "Send Motion", + v = "Send Visual", + f = "Send File", + l = "Send Line", + [""] = "Send Enter", + [""] = "Send Interrupt", + q = "Exit", + c = "Clear REPL", + m = { + name = "+mark", + s = "Send Mark", + m = "Mark Motion", + v = "Mark Visual", + r = "Remove Mark" + } + }, +}, { prefix = "" }) + +wk.register({ + r = { + name = "+iron", + v = "Send Visual", + m = { + name = "+mark", + v = "Mark Visual", + } + }, +}, { prefix = "", mode = "v"}) diff --git a/home/dot_config/nvim/lua/tstarr/packer.lua b/home/dot_config/nvim/lua/tstarr/packer.lua index db34a312..14acc7f8 100644 --- a/home/dot_config/nvim/lua/tstarr/packer.lua +++ b/home/dot_config/nvim/lua/tstarr/packer.lua @@ -37,5 +37,6 @@ return require('packer').startup(function(use) use ('nathangrigg/vim-beancount') use ('vimwiki/vimwiki') use ('folke/which-key.nvim') + use ('hkupty/iron.nvim') end)