我已将家庭管理器作为模块安装在薄片中。
Flake 和模块位于/etc/nixos/
.
我的家庭管理器文件链接到我在其中配置 neovim 的另一个文件,该文件位于/etc/nixos/config/nvim/nvim.nix
.
该文件的内容是
# neovim configuration file
pkgs:
{
enable = true;
vimAlias = true;
# A simple configuration for neovim (sourced files)
extraLuaConfig = ''
-- Indentation
vim.opt.smartindent = true
vim.opt.autoindent = true
-- UI settings
vim.opt.number = true
vim.opt.cursorline = true
'';
plugins = with pkgs.vimPlugins; [
vim-nix
yuck-vim
markdown-preview-nvim
{
plugin = telescope-nvim;
config = ''
" Find files using Telescope command-line sugar.
noremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" Using Lua functions
nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep()<cr>
nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>
'';
}
{
type = "lua";
plugin = catppuccin-nvim;
config = ''
require("catppuccin").setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha
background = { -- :h background
light = "latte",
dark = "mocha",
},
transparent_background = false,
show_end_of_buffer = false, -- show the '~' characters after the end of buffers
term_colors = false,
dim_inactive = {
enabled = false,
shade = "dark",
percentage = 0.15,
},
no_italic = false, -- Force no italic
no_bold = false, -- Force no bold
styles = {
comments = { "italic" },
conditionals = { "italic" },
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
},
color_overrides = {},
custom_highlights = {},
integrations = {
cmp = true,
gitsigns = true,
nvimtree = true,
telescope = true,
notify = false,
mini = false,
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
},
})
-- setup must be called before loading
vim.cmd.colorscheme "catppuccin"
'';
}
nvim-web-devicons
neo-tree-nvim
{
type = "lua";
plugin = nvim-treesitter;
config = ''
require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained",
highlight = {
enable = true,
}
}
'';
}
nvim-lspconfig
rust-tools-nvim
];
extraPackages = with pkgs; [
tree-sitter
rust-analyzer
ripgrep
nil
zig
ripgrep
kotlin-language-server
fd
statix
cppcheck
deadnix
alejandra
nodePackages.pyright
nodejs-16_x
tree-sitter
nil
clang-tools
cmake-language-server
# ccls
wl-clipboard
omnisharp-roslyn
netcoredbg
gcc # treesitter
nixfmt
nodePackages.typescript-language-server
python310Packages.autopep8
lazygit
];
}
当我打开文件时,例如,*.lua
我收到错误消息:
Error detected while processing /home/simon/.config/nvim/init.lua:
Could not create parser dir ' /nix/store/w3x3582xldrjymxbxz98lzlfmhazibmy-vim-pack-dir/pack/myNeovimPackages/start/nvim-treesitter/parser ': Vim:E739: Cannot create directory /nix/sto
re/w3x3582xldrjymxbxz98lzlfmhazibmy-vim-pack-dir/pack/myNeovimPackages/start/nvim-treesitter/parser: read-only file system
我怎样才能解决这个问题?任何帮助是极大的赞赏。
答案1
您可以使用 nvim-treesitter 安装 Tree Sitter 语法nvim-treesitter.withPlugins
。像这样的东西应该开箱即用
nvim-treesitter.withPlugins (ps: with ps; [ nix python ])
如果你想安装所有语法:
nvim-treesitter.withAllGrammars
这记录在NixOS 手册的 vim 部分
如果您不想使用 nix 安装 nvim-treesitter 语法,您可以将 设置parser_install_dir
为可写的,请注意,这可能无法开箱即用。
require("nvim-treesitter.configs").setup({
parser_install_dir = "/some/path/to/store/parsers",
})
:h nvim-treesitter-quickstart
这些信息可以通过在 neovim 中运行来找到。