1
0
Fork 0

nvim: REPL support

This commit is contained in:
Daniel Kempkens 2022-04-20 16:27:26 +02:00
parent 060ec29bd3
commit 9dcaa0255a
7 changed files with 82 additions and 30 deletions

View file

@ -9,7 +9,8 @@
telescope-ivy (telescope-themes.get_ivy)
telescope-dropdown (telescope-themes.get_dropdown)
npairs (require :nvim-autopairs)
gitsigns (require :gitsigns)]
gitsigns (require :gitsigns)
repl (require :nifoc.repl)]
(fn map-entry [key cmd opts]
(vim.tbl_extend :keep {1 key 2 cmd} opts))
@ -27,6 +28,10 @@
{:description "New File"})
(map-entry :<leader>ut :<cmd>UndotreeToggle<CR>
{:description "Toggle Undotree"})
(map-entry :<leader>c repl.toggle-shell
{:description "Toggle Shell"})
(map-entry :<leader>r repl.toggle-repl
{:description "Toggle REPL"})
;; Buffer
(map-entry :<leader>bl
#(telescope-builtin.buffers telescope-dropdown)
@ -112,7 +117,7 @@
(map-entry :<leader>ld
#(telescope-builtin.diagnostics (vim.tbl_extend :keep
telescope-ivy
{:bufnr 0}))
{: bufnr}))
{:description "LSP Document Diagnostics"
:opts {:buffer bufnr}})
(map-entry :<leader>lca
@ -138,5 +143,13 @@
{:description "Format Buffer"
:opts {:buffer bufnr}})]))
(fn mod.terminal-open [bufnr]
(let [map-opts {:noremap true :buffer bufnr}]
(keymap.set :t :<esc> "<C-\\><C-n>" map-opts)
(keymap.set :t :<C-h> "<C-\\><C-n><C-W>h" map-opts)
(keymap.set :t :<C-j> "<C-\\><C-n><C-W>j" map-opts)
(keymap.set :t :<C-k> "<C-\\><C-n><C-W>k" map-opts)
(keymap.set :t :<C-l> "<C-\\><C-n><C-W>l" map-opts)))
mod)

View file

@ -0,0 +1,25 @@
(let [mod {}
terminal-class (require :toggleterm.terminal)
terminal terminal-class.Terminal]
(local elixir (terminal:new {:cmd :iex :close_on_exit true}))
(local erlang (terminal:new {:cmd :erl :close_on_exit true}))
(local fennel (terminal:new {:cmd "fennel --repl" :close_on_exit true}))
(local fish (terminal:new {:cmd :fish :close_on_exit true}))
(local javascript (terminal:new {:cmd :node :close_on_exit true}))
(local nix (terminal:new {:cmd "nix repl" :close_on_exit true}))
(local ruby (terminal:new {:cmd :irb :close_on_exit true}))
;; Map filetype to REPL
(local repl-map {: elixir : erlang : fennel : fish : javascript : nix : ruby})
(fn mod.toggle-shell []
(let [shell (. repl-map :fish)]
(shell:toggle)))
(fn mod.toggle-repl []
(let [ft vim.bo.filetype
repl (. repl-map ft)]
(when (not= repl nil)
(repl:toggle))))
mod)

View file

@ -1,9 +1,15 @@
(let [toggleterm (require :toggleterm)]
(toggleterm.setup {:shell :fish :open_mapping :<C-t>})
(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]
(aucmd :TermOpen {:callback (fn []
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))
(set vim.opt_local.cursorline false)
(keymap.terminal-open opts.buf))
:group augroup})))

View file

@ -23,11 +23,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1648199409,
"narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
@ -73,11 +73,11 @@
]
},
"locked": {
"lastModified": 1650301786,
"narHash": "sha256-9rz9NqL+mC+BIggn2emuzZ+3MYogxVBTdsFK7E3Vv1k=",
"lastModified": 1650413050,
"narHash": "sha256-e4Ajk6n+xQnF4CmqZf42OaLxsqm4LpJHkofRh5wwad0=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "8d38ca886880265d523a66fe3da4d42e92ab0748",
"rev": "8ec13d33b17f246e03ddfea100b7c3a143255bea",
"type": "github"
},
"original": {
@ -96,11 +96,11 @@
},
"locked": {
"dir": "contrib",
"lastModified": 1650333806,
"narHash": "sha256-ZrnN9ssclGTChvomcqL4Uact8L9+yToywNwrjyUULgI=",
"lastModified": 1650436522,
"narHash": "sha256-/Z1I2F6J8j/1Wis1fsKViZWqkCmmA+gEsyITT0cXTgM=",
"owner": "neovim",
"repo": "neovim",
"rev": "147cc60d24f093b5154824889f2151489774ef33",
"rev": "a391cd517bb4f0d638da3f0aaaf57f98e153447e",
"type": "github"
},
"original": {
@ -119,11 +119,11 @@
]
},
"locked": {
"lastModified": 1650356316,
"narHash": "sha256-RojfPzSC+veD2SCugaMNJ9c+TzD9hPIToWkC2venhrU=",
"lastModified": 1650443062,
"narHash": "sha256-K0PAS1YfaEcUD5XACEifwKTnsyE6DyuPkoKiHPto+4U=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "1c8ffbfa48d212eb806e3ea3eeae4c6c444130d5",
"rev": "c744e2783e846836c2c05f9dbdcc464ad980f488",
"type": "github"
},
"original": {
@ -186,11 +186,11 @@
]
},
"locked": {
"lastModified": 1650328756,
"narHash": "sha256-rA/Pdrl/vBpl/URdkF03bb7N8fp111OIP7+Aqb+YOKE=",
"lastModified": 1650415318,
"narHash": "sha256-HZDhiEELVjhZf9pR0Y3cYVFI7SZVCiSc1g3yqvMYdFk=",
"owner": "arqv",
"repo": "zig-overlay",
"rev": "77597e467567b462efce312d1c99b5a6dc24ea92",
"rev": "da3b287c1d29761e576ad81ac94aed260744d20d",
"type": "github"
},
"original": {

View file

@ -1 +1,7 @@
self: super: { }
self: super: {
fennel-luajit = super.fennel.overrideAttrs (
o: rec {
buildInputs = [ super.luajit ];
}
);
}

View file

@ -49,13 +49,15 @@ in
# LSP Tools
deadnix
hadolint
fennel
fennel-luajit
fnlfmt
shellcheck
shfmt
statix
];
extraLuaPackages = with pkgs.luajitPackages; [ readline ];
plugins = (with customPlugins; [
# Fixes
impatient-nvim
@ -310,7 +312,7 @@ in
xdg.configFile."nvim" = {
source = pkgs.runCommand "nvim-fennel-files"
{
nativeBuildInputs = [ pkgs.fennel pkgs.stylua ];
nativeBuildInputs = with pkgs; [ fennel-luajit stylua ];
} ''
mkdir -p $out/lua/configuration
mkdir -p $out/lua/nifoc/utils

View file

@ -87,12 +87,12 @@
};
leap-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "leap.nvim";
version = "1650369149";
version = "1650440510";
src = pkgs.fetchFromGitHub {
owner = "ggandor";
repo = "leap.nvim";
rev = "4e4ce2bba4fa6c30fc9e8999e71dcc67386732b0";
sha256 = "TG5tAzr+erpTHiaL/VaJC4rMOcqY7abzhpN5lNsFnCs=";
rev = "2a7965c6ec3f5de9efde92dcec0c53f12c84732a";
sha256 = "VBhzMxYkUQfFFVgUM+ZDtgGoEFQRvcdWX8oH7h54+E8=";
fetchSubmodules = true;
};
meta.homepage = "https://github.com/ggandor/leap.nvim";
@ -238,12 +238,12 @@
};
nvim-cmp = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-cmp";
version = "1650365016";
version = "1650428497";
src = pkgs.fetchFromGitHub {
owner = "hrsh7th";
repo = "nvim-cmp";
rev = "07132dc597e94a8b6df75efce9784a581f55742c";
sha256 = "9wPv8mXax2fr1L6TeiFOSK7ZdXNg1v/1eRj00OFDw1Y=";
rev = "f51dc68e1bb170fc49c2d7e13eb45e5ec83f5ee9";
sha256 = "U5lDWtslhZuDZBgzSijFmOlNShP+geVJw3FIxKIfxYU=";
fetchSubmodules = true;
};
meta.homepage = "https://github.com/hrsh7th/nvim-cmp";