1
0
Fork 0

nvim: Replace toggleterm with wezterm splits

This commit is contained in:
Daniel Kempkens 2023-10-15 22:08:36 +02:00
parent f2e0c24cda
commit 3a430aaf62
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
9 changed files with 26 additions and 106 deletions

View file

@ -12,8 +12,7 @@
(usercmd :FormatEnableBuffer mod.enable-for-buffer (usercmd :FormatEnableBuffer mod.enable-for-buffer
{:desc "Enable Formatting for the current buffer"}) {:desc "Enable Formatting for the current buffer"})
(aucmd :BufWritePre (aucmd :BufWritePre
{:pattern "*" {:callback #(mod.maybe-format-buffer $1.buf)
:callback #(mod.maybe-format-buffer $1.buf)
:group augroup :group augroup
:desc "Run Formatter before saving"}))) :desc "Run Formatter before saving"})))
@ -42,6 +41,7 @@
(conform.format {: bufnr (conform.format {: bufnr
:async false :async false
:timeout_ms 1000 :timeout_ms 1000
:lsp_fallback (format-with-lsp? ft)})))) :lsp_fallback (format-with-lsp? ft)}))
nil))
mod) mod)

View file

@ -4,7 +4,6 @@
telescope-builtin (require :telescope.builtin) telescope-builtin (require :telescope.builtin)
telescope-themes (require :telescope.themes) telescope-themes (require :telescope.themes)
telescope-nifoc (require :nifoc.telescope) telescope-nifoc (require :nifoc.telescope)
telescope-toggleterm (require :telescope-toggleterm)
telescope-ivy (telescope-themes.get_ivy) telescope-ivy (telescope-themes.get_ivy)
telescope-dropdown (telescope-themes.get_dropdown) telescope-dropdown (telescope-themes.get_dropdown)
gitsigns (require :gitsigns) gitsigns (require :gitsigns)
@ -20,10 +19,8 @@
(keymap.set :n :<leader>u "<cmd>UrlView buffer<CR>" {:desc "Open UrlView"}) (keymap.set :n :<leader>u "<cmd>UrlView buffer<CR>" {:desc "Open UrlView"})
(keymap.set :n :<leader>ut "<cmd>Telescope undo<CR>" (keymap.set :n :<leader>ut "<cmd>Telescope undo<CR>"
{:desc "Toggle Undotree"}) {:desc "Toggle Undotree"})
(keymap.set :n :<leader>c repl.toggle-shell {:desc "Toggle Shell"}) (keymap.set :n :<leader>c repl.open-shell {:desc "Open Shell"})
(keymap.set :n :<leader>cs #(telescope-toggleterm.open telescope-dropdown) (keymap.set :n :<leader>r repl.open-repl {:desc "Open REPL"})
{:desc "Select Terminal"})
(keymap.set :n :<leader>r repl.toggle-repl {:desc "Toggle REPL"})
(keymap.set :n :<leader>bl #(telescope-builtin.buffers telescope-dropdown) (keymap.set :n :<leader>bl #(telescope-builtin.buffers telescope-dropdown)
{:desc "List Buffers"}) {:desc "List Buffers"})
(keymap.set :n :<leader>bf (keymap.set :n :<leader>bf
@ -40,8 +37,6 @@
{:desc "List VCS Branches"}) {:desc "List VCS Branches"})
(keymap.set :n :<leader>vl #(gitsigns.blame_line {:full true}) (keymap.set :n :<leader>vl #(gitsigns.blame_line {:full true})
{:desc "Blame Line"}) {:desc "Blame Line"})
(keymap.set :n :<leader>vc #(repl.toggle-specific-shell :vcs)
{:desc "Toggle VCS Shell"})
(keymap.set :n :<leader>lk telescope-builtin.keymaps (keymap.set :n :<leader>lk telescope-builtin.keymaps
{:desc "Show Keymappings"}) {:desc "Show Keymappings"})
(keymap.set :n :<leader>ld #(telescope-builtin.diagnostics telescope-ivy) (keymap.set :n :<leader>ld #(telescope-builtin.diagnostics telescope-ivy)

View file

@ -1,55 +1,31 @@
(let [mod {} (let [mod {}
terminal-class (require :toggleterm.terminal) wezterm (require :wezterm)]
terminal terminal-class.Terminal] (fn exe [bin] (vim.fn.exepath bin))
(fn repl-setup []
(set vim.b.nifoc_shell_mode :REPL))
(fn generic-setup [label] (fn split [program]
(set vim.b.nifoc_shell_mode label)) (let [args [:cli :split-pane :--bottom :--percent :30 "--"]]
(each [_ value (ipairs program)]
(table.insert args value))
(wezterm.exec args)))
(local elixir (terminal:new {:cmd :iex (local elixir [(exe :iex)])
:on_open repl-setup (local erlang [(exe :erl)])
:close_on_exit true})) (local fennel [(exe :fennel) :--repl])
(local erlang (terminal:new {:cmd :erl (local fish [(exe :fish)])
:on_open repl-setup (local javascript [(exe :node)])
:close_on_exit true})) (local nix [(exe :nix) :repl])
(local fennel (terminal:new {:cmd "fennel --repl" (local ruby [(exe :irb)])
:on_open repl-setup
:close_on_exit true}))
(local fish (terminal:new {:cmd :fish
:on_open #(generic-setup :SHELL)
:close_on_exit true}))
(local javascript (terminal:new {:cmd :node
:on_open repl-setup
:close_on_exit true}))
(local nix (terminal:new {:cmd "nix repl"
:on_open repl-setup
:close_on_exit true}))
(local ruby
(terminal:new {:cmd :irb :on_open repl-setup :close_on_exit true}))
;; Map filetype to REPL ;; Map filetype to REPL
(local repl-map {: elixir : erlang : fennel : fish : javascript : nix : ruby}) (local repl-map {: elixir : erlang : fennel : fish : javascript : nix : ruby})
;; Various specific shell windows
(local specific-shell
{:vcs (terminal:new {:cmd :fish
:on_open #(generic-setup :VCS)
:direction :float
:close_on_exit true
:float_opts {:border :rounded}})})
(fn mod.toggle-shell [] (fn mod.open-shell []
(let [shell (. repl-map :fish)] (let [shell (. repl-map :fish)]
(shell:toggle))) (split shell)))
(fn mod.toggle-repl [] (fn mod.open-repl []
(let [ft vim.bo.filetype (let [ft vim.bo.filetype
repl (. repl-map ft)] repl (. repl-map ft)]
(when (not= repl nil) (when (not= repl nil)
(repl:toggle)))) (split repl))))
(fn mod.toggle-specific-shell [name]
(let [shell (. specific-shell name)]
(shell:toggle)))
mod) mod)

View file

@ -31,7 +31,6 @@
:case_mode :smart_case}}}) :case_mode :smart_case}}})
(telescope.load_extension :fzf) (telescope.load_extension :fzf)
(telescope.load_extension :ui-select) (telescope.load_extension :ui-select)
(telescope.load_extension :toggleterm)
(telescope.load_extension :yank_history) (telescope.load_extension :yank_history)
(telescope.load_extension :undo) (telescope.load_extension :undo)
(let [augroup (vim.api.nvim_create_augroup :NifocTelescope {:clear true}) (let [augroup (vim.api.nvim_create_augroup :NifocTelescope {:clear true})
@ -47,4 +46,3 @@
(set vim.opt_local.relativenumber false) (set vim.opt_local.relativenumber false)
(set vim.opt_local.wrap true)) (set vim.opt_local.wrap true))
:group augroup}))) :group augroup})))

View file

@ -1,17 +0,0 @@
(let [toggleterm (require :toggleterm)]
(toggleterm.setup {:shell vim.o.shell
:open_mapping :<C-t>
:close_on_exit true})
(let [augroup (vim.api.nvim_create_augroup :NifocTerm {:clear true})
aucmd vim.api.nvim_create_autocmd
keymap (require :nifoc.keymap)]
(aucmd :TermOpen {:pattern "term://*toggleterm#*"
:callback (fn [opts]
(set vim.opt_local.number false)
(set vim.opt_local.relativenumber false)
(set vim.opt_local.cursorline false)
(vim.api.nvim_buf_set_var opts.buf
:toggle_line_style 0)
(keymap.terminal-open opts.buf))
:group augroup})))

View file

@ -182,7 +182,6 @@ in
} }
telescope-ui-select-nvim telescope-ui-select-nvim
telescope-toggleterm-nvim
telescope-undo-nvim telescope-undo-nvim
# Completion # Completion
@ -259,12 +258,6 @@ in
type = "fennel"; type = "fennel";
} }
{
plugin = toggleterm-nvim;
config = builtins.readFile ../../config/nvim/plugins/toggleterm.fnl;
type = "fennel";
}
{ {
plugin = urlview-nvim; plugin = urlview-nvim;
config = builtins.readFile ../../config/nvim/plugins/urlview.fnl; config = builtins.readFile ../../config/nvim/plugins/urlview.fnl;

View file

@ -2,7 +2,6 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs) fetchFromGitHub; inherit (pkgs) fetchFromGitHub;
inherit (pkgs) fetchFromSourcehut;
inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.vimUtils) buildVimPlugin;
in in
{ {
@ -122,8 +121,8 @@ in
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "nvim-treesitter"; owner = "nvim-treesitter";
repo = "nvim-treesitter"; repo = "nvim-treesitter";
rev = "f8fcb0da0618be551560a57fa1457dc6f889e568"; rev = "43694a240cce2fbaf3f573bd5e0864eefaf32e4f";
sha256 = "0nalh47rqfqhrhbpn6v2x9yijfln1kvxd2m676lr2mwf8362ppjc"; sha256 = "1kibm65xl762gs3vizqz5vgffb3l2r3z5css03smginnssd98y8l";
fetchSubmodules = false; fetchSubmodules = false;
}; };
}; };
@ -207,17 +206,6 @@ in
fetchSubmodules = false; fetchSubmodules = false;
}; };
}; };
telescope-toggleterm-nvim = buildVimPlugin {
pname = "telescope-toggleterm.nvim";
version = "2022-02-10";
src = fetchFromSourcehut {
owner = "~havi";
repo = "telescope-toggleterm.nvim";
rev = "5c1402507f0ad01711196e5d27e9f0606f78b7d0";
sha256 = "04vn8807gmhahhap55xjbabarlmqf05ygwqycsfkdcbm5jpcxdnw";
fetchSubmodules = false;
};
};
telescope-undo-nvim = buildVimPlugin { telescope-undo-nvim = buildVimPlugin {
pname = "telescope-undo.nvim"; pname = "telescope-undo.nvim";
version = "2023-06-03"; version = "2023-06-03";
@ -339,17 +327,6 @@ in
fetchSubmodules = false; fetchSubmodules = false;
}; };
}; };
toggleterm-nvim = buildVimPlugin {
pname = "toggleterm.nvim";
version = "2023-10-02";
src = fetchFromGitHub {
owner = "akinsho";
repo = "toggleterm.nvim";
rev = "c80844fd52ba76f48fabf83e2b9f9b93273f418d";
sha256 = "19rbq39m7c1v9yrfmlwmfmxgv5d9bwcjbgjdp3cin409fnl4rv6b";
fetchSubmodules = false;
};
};
urlview-nvim = buildVimPlugin { urlview-nvim = buildVimPlugin {
pname = "urlview.nvim"; pname = "urlview.nvim";
version = "2023-09-19"; version = "2023-09-19";

View file

@ -23,7 +23,6 @@
make make
- src: ahmedkhalf/project.nvim - src: ahmedkhalf/project.nvim
- src: nvim-telescope/telescope-ui-select.nvim - src: nvim-telescope/telescope-ui-select.nvim
- src: "https://git.sr.ht/~havi/telescope-toggleterm.nvim"
- src: debugloop/telescope-undo.nvim - src: debugloop/telescope-undo.nvim
# LSP # LSP
- src: neovim/nvim-lspconfig - src: neovim/nvim-lspconfig
@ -40,7 +39,6 @@
- src: rebelot/heirline.nvim - src: rebelot/heirline.nvim
- src: lukas-reineke/indent-blankline.nvim - src: lukas-reineke/indent-blankline.nvim
- src: lukas-reineke/virt-column.nvim - src: lukas-reineke/virt-column.nvim
- src: akinsho/toggleterm.nvim
- src: axieax/urlview.nvim - src: axieax/urlview.nvim
- src: lewis6991/gitsigns.nvim - src: lewis6991/gitsigns.nvim
- src: rcarriga/nvim-notify - src: rcarriga/nvim-notify

View file

@ -22,7 +22,7 @@ rm -f "$nix_new_file"
echo '{ pkgs, ... }:' echo '{ pkgs, ... }:'
echo 'let' echo 'let'
echo 'inherit (pkgs) fetchFromGitHub;' echo 'inherit (pkgs) fetchFromGitHub;'
echo 'inherit (pkgs) fetchFromSourcehut;' # echo 'inherit (pkgs) fetchFromSourcehut;'
echo 'inherit (pkgs.vimUtils) buildVimPlugin;' echo 'inherit (pkgs.vimUtils) buildVimPlugin;'
echo 'in' echo 'in'
echo '{' echo '{'