mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-07-11 23:22:40 +02:00
feat: access extraPackages in neovim's terminal - add a shell wrapper
This commit is contained in:
Generated
+4
-4
@@ -45,16 +45,16 @@
|
|||||||
"astronvim": {
|
"astronvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699528269,
|
"lastModified": 1701266895,
|
||||||
"narHash": "sha256-cC1isyscpvNQ07n/Eb6rlfvuQ/K+7mCjdGJq4m/PUHk=",
|
"narHash": "sha256-wttBcj9OoFHx+EukGzQYKHVlApphZXzZqY5zP5chU6g=",
|
||||||
"owner": "AstroNvim",
|
"owner": "AstroNvim",
|
||||||
"repo": "AstroNvim",
|
"repo": "AstroNvim",
|
||||||
"rev": "59d657c223038359b2b5e230805abca8d919280d",
|
"rev": "bdbc0fef3f33443251e6b45b252b98c42335b881",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "AstroNvim",
|
"owner": "AstroNvim",
|
||||||
"ref": "v3.37.12",
|
"ref": "v3.39.0",
|
||||||
"repo": "AstroNvim",
|
"repo": "AstroNvim",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -329,7 +329,7 @@
|
|||||||
|
|
||||||
# AstroNvim is an aesthetic and feature-rich neovim config.
|
# AstroNvim is an aesthetic and feature-rich neovim config.
|
||||||
astronvim = {
|
astronvim = {
|
||||||
url = "github:AstroNvim/AstroNvim/v3.37.12";
|
url = "github:AstroNvim/AstroNvim/v3.39.0";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
(python311.withPackages (
|
(python3.withPackages (
|
||||||
ps:
|
ps:
|
||||||
with ps; [
|
with ps; [
|
||||||
ipython
|
ipython
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ return {
|
|||||||
signcolumn = "auto", -- Show sign column when used only
|
signcolumn = "auto", -- Show sign column when used only
|
||||||
spell = false, -- Spell checking
|
spell = false, -- Spell checking
|
||||||
swapfile = false, -- Swapfile
|
swapfile = false, -- Swapfile
|
||||||
smartindent = false; -- fix https://github.com/ryan4yin/nix-config/issues/4
|
smartindent = false, -- fix https://github.com/ryan4yin/nix-config/issues/4
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -24,7 +24,6 @@ return {
|
|||||||
{ import = "astrocommunity.motion.leap-nvim" },
|
{ import = "astrocommunity.motion.leap-nvim" },
|
||||||
{ import = "astrocommunity.motion.flit-nvim" },
|
{ import = "astrocommunity.motion.flit-nvim" },
|
||||||
{ import = "astrocommunity.scrolling.nvim-scrollbar" },
|
{ import = "astrocommunity.scrolling.nvim-scrollbar" },
|
||||||
{ import = "astrocommunity.editing-support.auto-save-nvim" },
|
|
||||||
{ import = "astrocommunity.editing-support.todo-comments-nvim" },
|
{ import = "astrocommunity.editing-support.todo-comments-nvim" },
|
||||||
-- Language Support
|
-- Language Support
|
||||||
---- Frontend & NodeJS
|
---- Frontend & NodeJS
|
||||||
@@ -67,22 +66,36 @@ return {
|
|||||||
"zbirenbaum/copilot.lua",
|
"zbirenbaum/copilot.lua",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
opts.filetypes = {
|
opts.filetypes = {
|
||||||
yaml = true;
|
yaml = true,
|
||||||
markdown = true,
|
markdown = true,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"0x00-ketsu/autosave.nvim",
|
||||||
|
opts = function(_, opts)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"akinsho/toggleterm.nvim",
|
||||||
|
opts = function(_, opts)
|
||||||
|
-- custom shell with all neovim's exra packags accessible
|
||||||
|
opts.shell = "nvim-nushell";
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
-- markdown preview
|
-- markdown preview
|
||||||
{
|
{
|
||||||
'0x00-ketsu/markdown-preview.nvim',
|
"0x00-ketsu/markdown-preview.nvim",
|
||||||
ft = {'md', 'markdown', 'mkd', 'mkdn', 'mdwn', 'mdown', 'mdtxt', 'mdtext', 'rmd', 'wiki'},
|
ft = { "md", "markdown", "mkd", "mkdn", "mdwn", "mdown", "mdtxt", "mdtext", "rmd", "wiki" },
|
||||||
config = function()
|
config = function()
|
||||||
require('markdown-preview').setup {
|
require("markdown-preview").setup({
|
||||||
-- your configuration comes here
|
-- your configuration comes here
|
||||||
-- or leave it empty to use the default settings
|
-- or leave it empty to use the default settings
|
||||||
-- refer to the setup section below
|
-- refer to the setup section below
|
||||||
}
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -90,7 +103,7 @@ return {
|
|||||||
{
|
{
|
||||||
"gbprod/yanky.nvim",
|
"gbprod/yanky.nvim",
|
||||||
opts = function()
|
opts = function()
|
||||||
local mapping = require "yanky.telescope.mapping"
|
local mapping = require("yanky.telescope.mapping")
|
||||||
local mappings = mapping.get_defaults()
|
local mappings = mapping.get_defaults()
|
||||||
mappings.i["<c-p>"] = nil
|
mappings.i["<c-p>"] = nil
|
||||||
return {
|
return {
|
||||||
@@ -140,11 +153,12 @@ return {
|
|||||||
|
|
||||||
-- joining blocks of code into oneline, or splitting one line into multiple lines.
|
-- joining blocks of code into oneline, or splitting one line into multiple lines.
|
||||||
{
|
{
|
||||||
'Wansmer/treesj',
|
"Wansmer/treesj",
|
||||||
keys = { '<space>m', '<space>j', '<space>s' },
|
keys = { "<space>m", "<space>j", "<space>s" },
|
||||||
dependencies = { 'nvim-treesitter/nvim-treesitter' },
|
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
||||||
config = function()
|
config = function()
|
||||||
require('treesj').setup({--[[ your config ]]})
|
require("treesj").setup({ --[[ your config ]]
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -159,22 +173,22 @@ return {
|
|||||||
hide_gitignored = false,
|
hide_gitignored = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
-- The plugin offers the alibity to refactor code.
|
-- The plugin offers the alibity to refactor code.
|
||||||
{
|
{
|
||||||
"ThePrimeagen/refactoring.nvim",
|
"ThePrimeagen/refactoring.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{"nvim-lua/plenary.nvim"},
|
{ "nvim-lua/plenary.nvim" },
|
||||||
{"nvim-treesitter/nvim-treesitter"}
|
{ "nvim-treesitter/nvim-treesitter" },
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
-- The plugin offers the abilibty to search and replace.
|
-- The plugin offers the abilibty to search and replace.
|
||||||
{
|
{
|
||||||
"nvim-pack/nvim-spectre",
|
"nvim-pack/nvim-spectre",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{"nvim-lua/plenary.nvim"},
|
{ "nvim-lua/plenary.nvim" },
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- full signature help, docs and completion for the nvim lua API.
|
-- full signature help, docs and completion for the nvim lua API.
|
||||||
@@ -186,7 +200,7 @@ return {
|
|||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
local utils = require "astronvim.utils";
|
local utils = require("astronvim.utils")
|
||||||
opts.incremental_selection = {
|
opts.incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
@@ -213,14 +227,14 @@ return {
|
|||||||
|
|
||||||
-- implementation/definition preview
|
-- implementation/definition preview
|
||||||
{
|
{
|
||||||
'rmagatti/goto-preview',
|
"rmagatti/goto-preview",
|
||||||
config = function()
|
config = function()
|
||||||
require('goto-preview').setup {}
|
require("goto-preview").setup({})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Undo tree
|
-- Undo tree
|
||||||
{ "debugloop/telescope-undo.nvim", },
|
{ "debugloop/telescope-undo.nvim" },
|
||||||
|
|
||||||
-- Install lsp, formmatter and others via home manager instead of Mason.nvim
|
-- Install lsp, formmatter and others via home manager instead of Mason.nvim
|
||||||
-- LSP installations
|
-- LSP installations
|
||||||
@@ -245,7 +259,7 @@ return {
|
|||||||
{
|
{
|
||||||
"jose-elias-alvarez/null-ls.nvim",
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
local null_ls = require "null-ls"
|
local null_ls = require("null-ls")
|
||||||
local code_actions = null_ls.builtins.code_actions
|
local code_actions = null_ls.builtins.code_actions
|
||||||
local diagnostics = null_ls.builtins.diagnostics
|
local diagnostics = null_ls.builtins.diagnostics
|
||||||
local formatting = null_ls.builtins.formatting
|
local formatting = null_ls.builtins.formatting
|
||||||
@@ -302,8 +316,9 @@ return {
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
'nvim-telescope/telescope.nvim', branch = '0.1.x',
|
"nvim-telescope/telescope.nvim",
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
branch = "0.1.x",
|
||||||
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
init = function()
|
init = function()
|
||||||
-- 1. Disable highlighting for certain filetypes
|
-- 1. Disable highlighting for certain filetypes
|
||||||
-- 2. Ignore files larger than a certain filesize
|
-- 2. Ignore files larger than a certain filesize
|
||||||
@@ -322,7 +337,9 @@ return {
|
|||||||
|
|
||||||
local new_maker = function(filepath, bufnr, opts)
|
local new_maker = function(filepath, bufnr, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
if opts.use_ft_detect == nil then opts.use_ft_detect = true end
|
if opts.use_ft_detect == nil then
|
||||||
|
opts.use_ft_detect = true
|
||||||
|
end
|
||||||
|
|
||||||
-- 1. Check if the file is in the bad_files array, and if so, don't highlight it
|
-- 1. Check if the file is in the bad_files array, and if so, don't highlight it
|
||||||
opts.use_ft_detect = opts.use_ft_detect == false and false or bad_files(filepath)
|
opts.use_ft_detect = opts.use_ft_detect == false and false or bad_files(filepath)
|
||||||
@@ -330,7 +347,9 @@ return {
|
|||||||
-- 2. Check the file size, and ignore it if it's too big(preview nothing).
|
-- 2. Check the file size, and ignore it if it's too big(preview nothing).
|
||||||
filepath = vim.fn.expand(filepath)
|
filepath = vim.fn.expand(filepath)
|
||||||
vim.loop.fs_stat(filepath, function(_, stat)
|
vim.loop.fs_stat(filepath, function(_, stat)
|
||||||
if not stat then return end
|
if not stat then
|
||||||
|
return
|
||||||
|
end
|
||||||
if stat.size > filesize_threshold then
|
if stat.size > filesize_threshold then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
@@ -339,13 +358,13 @@ return {
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
require("telescope").setup {
|
require("telescope").setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
buffer_previewer_maker = new_maker,
|
buffer_previewer_maker = new_maker,
|
||||||
}
|
},
|
||||||
}
|
})
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Configure require("lazy").setup() options
|
-- Configure require("lazy").setup() options
|
||||||
@@ -354,7 +373,7 @@ return {
|
|||||||
performance = {
|
performance = {
|
||||||
rtp = {
|
rtp = {
|
||||||
-- customize default disabled vim plugins
|
-- customize default disabled vim plugins
|
||||||
disabled_plugins = { };
|
disabled_plugins = {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,12 @@ return {
|
|||||||
["<leader>bn"] = { "<cmd>tabnew<cr>", desc = "New tab" },
|
["<leader>bn"] = { "<cmd>tabnew<cr>", desc = "New tab" },
|
||||||
-- quick save
|
-- quick save
|
||||||
["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
|
["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
|
||||||
["<leader>tp"] = { function() utils.toggle_term_cmd("ipython") end, desc = "ToggleTerm python" },
|
|
||||||
|
-- Terminal
|
||||||
|
-- NOTE: https://neovim.io/doc/user/builtin.html#jobstart()
|
||||||
|
-- 1. If {cmd} is a List it runs directly (no 'shell')
|
||||||
|
-- 2. If {cmd} is a String it runs in the 'shell'
|
||||||
|
["<leader>tp"] = { function() utils.toggle_term_cmd({ cmd = "ipython" }) end, desc = "ToggleTerm python" },
|
||||||
|
|
||||||
-- search and replace globally
|
-- search and replace globally
|
||||||
['<leader>ss'] = {'<cmd>lua require("spectre").toggle()<CR>', desc = "Toggle Spectre" },
|
['<leader>ss'] = {'<cmd>lua require("spectre").toggle()<CR>', desc = "Toggle Spectre" },
|
||||||
|
|||||||
@@ -27,16 +27,19 @@
|
|||||||
programs = {
|
programs = {
|
||||||
neovim = {
|
neovim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
defaultEditor = true;
|
|
||||||
|
|
||||||
viAlias = false;
|
defaultEditor = true;
|
||||||
|
viAlias = true;
|
||||||
vimAlias = true;
|
vimAlias = true;
|
||||||
|
|
||||||
withPython3 = true;
|
# currently we use lazy.nvim as neovim's package manager, so comment this one.
|
||||||
withNodeJs = true;
|
# plugins = with pkgs.vimPlugins; [
|
||||||
|
# # search all the plugins using https://search.nixos.org/packages
|
||||||
|
# ];
|
||||||
|
|
||||||
# Extra packages only available to nvim(won't pollute the global home environment)
|
# Extra packages only available to nvim(won't pollute the global home environment)
|
||||||
extraPackages = with pkgs;
|
extraPackages = with pkgs; let
|
||||||
|
nvim_extra =
|
||||||
[
|
[
|
||||||
#-- c/c++
|
#-- c/c++
|
||||||
cmake
|
cmake
|
||||||
@@ -50,8 +53,20 @@
|
|||||||
|
|
||||||
#-- python
|
#-- python
|
||||||
nodePackages.pyright # python language server
|
nodePackages.pyright # python language server
|
||||||
python311Packages.black # python formatter
|
python3Packages.black # python formatter
|
||||||
python311Packages.ruff-lsp
|
python3Packages.ruff-lsp
|
||||||
|
(python3.withPackages (
|
||||||
|
ps:
|
||||||
|
with ps; [
|
||||||
|
pynvim # Python client and plugin host for Nvim
|
||||||
|
|
||||||
|
ipython
|
||||||
|
pandas
|
||||||
|
requests
|
||||||
|
pyquery
|
||||||
|
pyyaml
|
||||||
|
]
|
||||||
|
))
|
||||||
|
|
||||||
#-- rust
|
#-- rust
|
||||||
rust-analyzer
|
rust-analyzer
|
||||||
@@ -94,6 +109,7 @@
|
|||||||
shfmt
|
shfmt
|
||||||
|
|
||||||
#-- javascript/typescript --#
|
#-- javascript/typescript --#
|
||||||
|
nodePackages.nodejs
|
||||||
nodePackages.typescript
|
nodePackages.typescript
|
||||||
nodePackages.typescript-language-server
|
nodePackages.typescript-language-server
|
||||||
# HTML/CSS/JSON/ESLint language servers extracted from vscode
|
# HTML/CSS/JSON/ESLint language servers extracted from vscode
|
||||||
@@ -136,11 +152,27 @@
|
|||||||
verible
|
verible
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
in
|
||||||
|
nvim_extra
|
||||||
|
++ [
|
||||||
|
# NOTE: shells installed by Nix will ignore the `PATH` env passed by parent process,
|
||||||
|
# so to access the packages we installed here in neovim's shell session(`:terminal`),
|
||||||
|
# we have to create a shell wrapper with the packages in `PATH` env.
|
||||||
|
(pkgs.runCommand "nvim-shell" rec {
|
||||||
|
nativeBuildInputs =
|
||||||
|
nvim_extra
|
||||||
|
++ [
|
||||||
|
pkgs.nushell
|
||||||
|
pkgs.bash
|
||||||
|
];
|
||||||
|
PATH = lib.makeBinPath nativeBuildInputs;
|
||||||
|
} ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
|
||||||
# currently we use lazy.nvim as neovim's package manager, so comment this one.
|
ln -s ${pkgs.nushell}/bin/nu $out/bin/nvim-nushell
|
||||||
# plugins = with pkgs.vimPlugins; [
|
ln -s ${pkgs.bash}/bin/bash $out/bin/nvim-bash
|
||||||
# # search all the plugins using https://search.nixos.org/packages
|
'')
|
||||||
# ];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
# homebrew need to be installed manually, see https://brew.sh
|
# homebrew need to be installed manually, see https://brew.sh
|
||||||
homebrew = {
|
homebrew = {
|
||||||
enable = true;
|
enable = false;
|
||||||
|
|
||||||
onActivation = {
|
onActivation = {
|
||||||
autoUpdate = false;
|
autoUpdate = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user