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

View file

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

View file

@ -1,55 +1,31 @@
(let [mod {}
terminal-class (require :toggleterm.terminal)
terminal terminal-class.Terminal]
(fn repl-setup []
(set vim.b.nifoc_shell_mode :REPL))
wezterm (require :wezterm)]
(fn exe [bin] (vim.fn.exepath bin))
(fn generic-setup [label]
(set vim.b.nifoc_shell_mode label))
(fn split [program]
(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
:on_open repl-setup
:close_on_exit true}))
(local erlang (terminal:new {:cmd :erl
:on_open repl-setup
:close_on_exit true}))
(local fennel (terminal:new {:cmd "fennel --repl"
: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}))
(local elixir [(exe :iex)])
(local erlang [(exe :erl)])
(local fennel [(exe :fennel) :--repl])
(local fish [(exe :fish)])
(local javascript [(exe :node)])
(local nix [(exe :nix) :repl])
(local ruby [(exe :irb)])
;; Map filetype to REPL
(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)]
(shell:toggle)))
(split shell)))
(fn mod.toggle-repl []
(fn mod.open-repl []
(let [ft vim.bo.filetype
repl (. repl-map ft)]
(when (not= repl nil)
(repl:toggle))))
(fn mod.toggle-specific-shell [name]
(let [shell (. specific-shell name)]
(shell:toggle)))
(split repl))))
mod)

View file

@ -31,7 +31,6 @@
:case_mode :smart_case}}})
(telescope.load_extension :fzf)
(telescope.load_extension :ui-select)
(telescope.load_extension :toggleterm)
(telescope.load_extension :yank_history)
(telescope.load_extension :undo)
(let [augroup (vim.api.nvim_create_augroup :NifocTelescope {:clear true})
@ -47,4 +46,3 @@
(set vim.opt_local.relativenumber false)
(set vim.opt_local.wrap true))
: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-toggleterm-nvim
telescope-undo-nvim
# Completion
@ -259,12 +258,6 @@ in
type = "fennel";
}
{
plugin = toggleterm-nvim;
config = builtins.readFile ../../config/nvim/plugins/toggleterm.fnl;
type = "fennel";
}
{
plugin = urlview-nvim;
config = builtins.readFile ../../config/nvim/plugins/urlview.fnl;

View file

@ -2,7 +2,6 @@
{ pkgs, ... }:
let
inherit (pkgs) fetchFromGitHub;
inherit (pkgs) fetchFromSourcehut;
inherit (pkgs.vimUtils) buildVimPlugin;
in
{
@ -122,8 +121,8 @@ in
src = fetchFromGitHub {
owner = "nvim-treesitter";
repo = "nvim-treesitter";
rev = "f8fcb0da0618be551560a57fa1457dc6f889e568";
sha256 = "0nalh47rqfqhrhbpn6v2x9yijfln1kvxd2m676lr2mwf8362ppjc";
rev = "43694a240cce2fbaf3f573bd5e0864eefaf32e4f";
sha256 = "1kibm65xl762gs3vizqz5vgffb3l2r3z5css03smginnssd98y8l";
fetchSubmodules = false;
};
};
@ -207,17 +206,6 @@ in
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 {
pname = "telescope-undo.nvim";
version = "2023-06-03";
@ -339,17 +327,6 @@ in
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 {
pname = "urlview.nvim";
version = "2023-09-19";

View file

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

View file

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