nvim: REPL support
This commit is contained in:
parent
060ec29bd3
commit
9dcaa0255a
7 changed files with 82 additions and 30 deletions
|
@ -9,7 +9,8 @@
|
||||||
telescope-ivy (telescope-themes.get_ivy)
|
telescope-ivy (telescope-themes.get_ivy)
|
||||||
telescope-dropdown (telescope-themes.get_dropdown)
|
telescope-dropdown (telescope-themes.get_dropdown)
|
||||||
npairs (require :nvim-autopairs)
|
npairs (require :nvim-autopairs)
|
||||||
gitsigns (require :gitsigns)]
|
gitsigns (require :gitsigns)
|
||||||
|
repl (require :nifoc.repl)]
|
||||||
(fn map-entry [key cmd opts]
|
(fn map-entry [key cmd opts]
|
||||||
(vim.tbl_extend :keep {1 key 2 cmd} opts))
|
(vim.tbl_extend :keep {1 key 2 cmd} opts))
|
||||||
|
|
||||||
|
@ -27,6 +28,10 @@
|
||||||
{:description "New File"})
|
{:description "New File"})
|
||||||
(map-entry :<leader>ut :<cmd>UndotreeToggle<CR>
|
(map-entry :<leader>ut :<cmd>UndotreeToggle<CR>
|
||||||
{:description "Toggle Undotree"})
|
{:description "Toggle Undotree"})
|
||||||
|
(map-entry :<leader>c repl.toggle-shell
|
||||||
|
{:description "Toggle Shell"})
|
||||||
|
(map-entry :<leader>r repl.toggle-repl
|
||||||
|
{:description "Toggle REPL"})
|
||||||
;; Buffer
|
;; Buffer
|
||||||
(map-entry :<leader>bl
|
(map-entry :<leader>bl
|
||||||
#(telescope-builtin.buffers telescope-dropdown)
|
#(telescope-builtin.buffers telescope-dropdown)
|
||||||
|
@ -112,7 +117,7 @@
|
||||||
(map-entry :<leader>ld
|
(map-entry :<leader>ld
|
||||||
#(telescope-builtin.diagnostics (vim.tbl_extend :keep
|
#(telescope-builtin.diagnostics (vim.tbl_extend :keep
|
||||||
telescope-ivy
|
telescope-ivy
|
||||||
{:bufnr 0}))
|
{: bufnr}))
|
||||||
{:description "LSP Document Diagnostics"
|
{:description "LSP Document Diagnostics"
|
||||||
:opts {:buffer bufnr}})
|
:opts {:buffer bufnr}})
|
||||||
(map-entry :<leader>lca
|
(map-entry :<leader>lca
|
||||||
|
@ -138,5 +143,13 @@
|
||||||
{:description "Format Buffer"
|
{:description "Format Buffer"
|
||||||
:opts {:buffer bufnr}})]))
|
: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)
|
mod)
|
||||||
|
|
||||||
|
|
25
config/nvim/nifoc/repl.fnl
Normal file
25
config/nvim/nifoc/repl.fnl
Normal 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)
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
(let [toggleterm (require :toggleterm)]
|
(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})
|
(let [augroup (vim.api.nvim_create_augroup :NifocTerm {:clear true})
|
||||||
aucmd vim.api.nvim_create_autocmd]
|
aucmd vim.api.nvim_create_autocmd
|
||||||
(aucmd :TermOpen {:callback (fn []
|
keymap (require :nifoc.keymap)]
|
||||||
|
(aucmd :TermOpen {:pattern "term://*toggleterm#*"
|
||||||
|
:callback (fn [opts]
|
||||||
(set vim.opt_local.number false)
|
(set vim.opt_local.number false)
|
||||||
(set vim.opt_local.relativenumber 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})))
|
:group augroup})))
|
||||||
|
|
||||||
|
|
30
flake.lock
30
flake.lock
|
@ -23,11 +23,11 @@
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1648199409,
|
"lastModified": 1650374568,
|
||||||
"narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
|
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||||
"owner": "edolstra",
|
"owner": "edolstra",
|
||||||
"repo": "flake-compat",
|
"repo": "flake-compat",
|
||||||
"rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
|
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -73,11 +73,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1650301786,
|
"lastModified": 1650413050,
|
||||||
"narHash": "sha256-9rz9NqL+mC+BIggn2emuzZ+3MYogxVBTdsFK7E3Vv1k=",
|
"narHash": "sha256-e4Ajk6n+xQnF4CmqZf42OaLxsqm4LpJHkofRh5wwad0=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "8d38ca886880265d523a66fe3da4d42e92ab0748",
|
"rev": "8ec13d33b17f246e03ddfea100b7c3a143255bea",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -96,11 +96,11 @@
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "contrib",
|
"dir": "contrib",
|
||||||
"lastModified": 1650333806,
|
"lastModified": 1650436522,
|
||||||
"narHash": "sha256-ZrnN9ssclGTChvomcqL4Uact8L9+yToywNwrjyUULgI=",
|
"narHash": "sha256-/Z1I2F6J8j/1Wis1fsKViZWqkCmmA+gEsyITT0cXTgM=",
|
||||||
"owner": "neovim",
|
"owner": "neovim",
|
||||||
"repo": "neovim",
|
"repo": "neovim",
|
||||||
"rev": "147cc60d24f093b5154824889f2151489774ef33",
|
"rev": "a391cd517bb4f0d638da3f0aaaf57f98e153447e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -119,11 +119,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1650356316,
|
"lastModified": 1650443062,
|
||||||
"narHash": "sha256-RojfPzSC+veD2SCugaMNJ9c+TzD9hPIToWkC2venhrU=",
|
"narHash": "sha256-K0PAS1YfaEcUD5XACEifwKTnsyE6DyuPkoKiHPto+4U=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "neovim-nightly-overlay",
|
"repo": "neovim-nightly-overlay",
|
||||||
"rev": "1c8ffbfa48d212eb806e3ea3eeae4c6c444130d5",
|
"rev": "c744e2783e846836c2c05f9dbdcc464ad980f488",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -186,11 +186,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1650328756,
|
"lastModified": 1650415318,
|
||||||
"narHash": "sha256-rA/Pdrl/vBpl/URdkF03bb7N8fp111OIP7+Aqb+YOKE=",
|
"narHash": "sha256-HZDhiEELVjhZf9pR0Y3cYVFI7SZVCiSc1g3yqvMYdFk=",
|
||||||
"owner": "arqv",
|
"owner": "arqv",
|
||||||
"repo": "zig-overlay",
|
"repo": "zig-overlay",
|
||||||
"rev": "77597e467567b462efce312d1c99b5a6dc24ea92",
|
"rev": "da3b287c1d29761e576ad81ac94aed260744d20d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1 +1,7 @@
|
||||||
self: super: { }
|
self: super: {
|
||||||
|
fennel-luajit = super.fennel.overrideAttrs (
|
||||||
|
o: rec {
|
||||||
|
buildInputs = [ super.luajit ];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -49,13 +49,15 @@ in
|
||||||
# LSP Tools
|
# LSP Tools
|
||||||
deadnix
|
deadnix
|
||||||
hadolint
|
hadolint
|
||||||
fennel
|
fennel-luajit
|
||||||
fnlfmt
|
fnlfmt
|
||||||
shellcheck
|
shellcheck
|
||||||
shfmt
|
shfmt
|
||||||
statix
|
statix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
extraLuaPackages = with pkgs.luajitPackages; [ readline ];
|
||||||
|
|
||||||
plugins = (with customPlugins; [
|
plugins = (with customPlugins; [
|
||||||
# Fixes
|
# Fixes
|
||||||
impatient-nvim
|
impatient-nvim
|
||||||
|
@ -310,7 +312,7 @@ in
|
||||||
xdg.configFile."nvim" = {
|
xdg.configFile."nvim" = {
|
||||||
source = pkgs.runCommand "nvim-fennel-files"
|
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/configuration
|
||||||
mkdir -p $out/lua/nifoc/utils
|
mkdir -p $out/lua/nifoc/utils
|
||||||
|
|
|
@ -87,12 +87,12 @@
|
||||||
};
|
};
|
||||||
leap-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
leap-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||||
pname = "leap.nvim";
|
pname = "leap.nvim";
|
||||||
version = "1650369149";
|
version = "1650440510";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "ggandor";
|
owner = "ggandor";
|
||||||
repo = "leap.nvim";
|
repo = "leap.nvim";
|
||||||
rev = "4e4ce2bba4fa6c30fc9e8999e71dcc67386732b0";
|
rev = "2a7965c6ec3f5de9efde92dcec0c53f12c84732a";
|
||||||
sha256 = "TG5tAzr+erpTHiaL/VaJC4rMOcqY7abzhpN5lNsFnCs=";
|
sha256 = "VBhzMxYkUQfFFVgUM+ZDtgGoEFQRvcdWX8oH7h54+E8=";
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
};
|
};
|
||||||
meta.homepage = "https://github.com/ggandor/leap.nvim";
|
meta.homepage = "https://github.com/ggandor/leap.nvim";
|
||||||
|
@ -238,12 +238,12 @@
|
||||||
};
|
};
|
||||||
nvim-cmp = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
nvim-cmp = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||||
pname = "nvim-cmp";
|
pname = "nvim-cmp";
|
||||||
version = "1650365016";
|
version = "1650428497";
|
||||||
src = pkgs.fetchFromGitHub {
|
src = pkgs.fetchFromGitHub {
|
||||||
owner = "hrsh7th";
|
owner = "hrsh7th";
|
||||||
repo = "nvim-cmp";
|
repo = "nvim-cmp";
|
||||||
rev = "07132dc597e94a8b6df75efce9784a581f55742c";
|
rev = "f51dc68e1bb170fc49c2d7e13eb45e5ec83f5ee9";
|
||||||
sha256 = "9wPv8mXax2fr1L6TeiFOSK7ZdXNg1v/1eRj00OFDw1Y=";
|
sha256 = "U5lDWtslhZuDZBgzSijFmOlNShP+geVJw3FIxKIfxYU=";
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
};
|
};
|
||||||
meta.homepage = "https://github.com/hrsh7th/nvim-cmp";
|
meta.homepage = "https://github.com/hrsh7th/nvim-cmp";
|
||||||
|
|
Loading…
Reference in a new issue