Git Product home page Git Product logo

nvim's Introduction

My Neovim Configuration

badge

Features

  • Handy and Smoothy: There will always be a panel to remind you when you forget your key settings. There will always be a short keystroke to help you get to the place you want to jump to. There will always…
  • Powerful coding experience: nvim-lspconfig powered great LSP experient.
  • Fancy looking: Well designed, denoised, uncluttered UI. Talk is cheap, see the gallery.
  • Great Performance: Lazy loading anywhere, you will never have to worry about accidental opening of a file larger than 10000 loc can freeze your terminal.

Getting Start

This configuration is compatible with neovim 0.8+ version.

git clone --depth=1 https://github.com/Avimitin/nvim.git ~/.config/nvim

Finally, input nvim to open the editor, and all plugins will be downloaded automatically.

nvim

To use this in your home-manager, you can use the xdg.configFile attribute:

{ pkgs }:
{
    xdg.configFile = {
        neovim = {
            target = "nvim";
            source = pkgs.fetchFromGitHub {
                repo = "nvim";
                owner = "Avimitin";
                rev = "...";
                hash = "...";
            }
        };
    };
}

Project Structure

  • lua: the configuration core

    • key-mapping.lua: my modification to the built-in key mappings
    • pack.lua: script to download lazy.nvim plugin manager
    • core/: my modification to the built-in options and auto commands
    • completion/: plugins and configuration for LSP and vim command completion
    • git/: plugin and configuration for using git in Neovim
    • lang/: plugins and configuration for using LSP server and get diagnostic in Neovim
    • libs/: functions that I don't want to write twice
    • note/: markdown and neorg support for neovim
    • tools/: miscellaneous plugins that can enhance editing experience
    • treesitter/: plugins for text object highlight and editing
    • ui/: plugins for decorating the neovim
  • after/ftplugin/<lang>.lua: configured LSP settings for each different language

  • ftdetect: list of script to help neovim identify filetype for some file

  • indent: list of script to help neovim properly set indentation

  • syntax: additional syntax detection for some file type

  • vsnip: my snippets

Treesitter parsers in nix

Ignore this if you are not a nix user

To make treesitter compatible with the stable neovim and my current configuration, and to make the share library compilation process reproducible and clean, this configuration provides a custom treesitter parser nix builder to manage the treesitter parser plugin. The flake output an overlay providing a nix function generate-nvim-treesitter-parsers. To use it, you can use home-manager to help you put this package into neovim's data directory.

Below is an example named laptop.nix, which show an example of how to link the lua script in $XDG_DATA_HOME to let neovim automatically load those parsers:

{ pkgs, ... }:
{
    xdg.dataFile.generate-nvim-treesitter-parsers = let
        tsLoader = pkgs.generate-nvim-treesitter-parsers [
          { name = "bash"; hash = "sha256-b1r/T+Y4Kmui/pHsncozP8OO6rMMHJj+Xaa2Qzwo/cI="; }
          { name = "c"; hash = "sha256-sB8fNfusjC9yTlrizb2mufDzQPvBajTJC+ewF9awBqA="; }
          { name = "cpp"; hash = "sha256-27QjVy8quWyGhFCv/6GATG1xjGnkB9LTcvlPMuR3NB0="; }
        ];
      in
      {
        source = "${tsLoader}${tsLoader.passthru.luaPath}";
        # Target will be substitute into ~/.local/share/nvim/site/plugin/treesitter-parsers.lua, and neovim will automatically load script in this path.
        target = "nvim/site/plugin/treesitter-parsers.lua";
      };
}

The array expect the argument in this form: [{ name: xxx; hash: xxx; }, ...], where:

  • name string: The name of the language
  • hash string: The input hash, you can leave it blank and wait for nix hash report the correct hash
  • needs_generate bool: When true, tree-sitter CLI will be used to generate the parser.
  • srcRoot string: Specify where the parser source located. Some repository will vendor two or more parser source code in one repository.

See my home configuration for detail examples.

Also you might found update the parser hash one by one really annoying, so the generate-nvim-treesitter-parsers also contains a update script. To use it, first you will need to place the script file somewhere:

xdg.dataFile =
let
  tsLoader = pkgs.generate-nvim-treesitter-parsers [
    { name = "bash"; hash = "sha256-b1r/T+Y4Kmui/pHsncozP8OO6rMMHJj+Xaa2Qzwo/cI="; }
    { name = "c"; hash = "sha256-sB8fNfusjC9yTlrizb2mufDzQPvBajTJC+ewF9awBqA="; }
    { name = "cpp"; hash = "sha256-27QjVy8quWyGhFCv/6GATG1xjGnkB9LTcvlPMuR3NB0="; }
    { name = "yaml"; hash = "sha256-RrYFKrhqFLsjQG+7XFbcQ2eYy2eyig5/r+MYO8DId4g="; }
  ];
in
{
  nvim-treesitter-parsers = {
    source = "${tsLoader}${tsLoader.passthru.luaPath}";
    target = "nvim/site/plugin/treesitter-parsers.lua";
  };
  nvim-treesitter-updater = {
    source = "${tsLoader.passthru.updateScript}/bin/treesitter-hash-batch-updater";
    target = "nvim/assets/treesitter-updater.bash"; # or any other path you like
  };
};

This script accept single argument, which should point to the hash definition file. In our example above, it is the 'laptop.nix' file, so run the bash script ~/.local/share/nvim/assets/treesitter-updater.bash laptop.nix, and wait for it finish its job.

Gallery

Utilities
Easy in-file jump
LightSpeed
Markdown Utils
Markdown Preview
image
Table
vim-table-mode-gif
Coding Utils
LSP Progress
image
Symbol Tree
image
Code Completion
coding
Command Completion
cmp-cmdline
Errorlens Like diagnostic
lsp-line
Signature Help
lsp-popup
Code Actions
lsp-codeaction
Diagnostic
lsp-diagnostic
Code navigate
Navigate
Project grep
live-grep
Symbol search
symbols
File Manager
neotree
nvim-tree
Find file
find-file
Themes
Kanagawa Theme
kanagawa

License

This configuration since commit 912416ae9c4b55501b23a91d774b567ba8697dd1 are licenced under the Apache 2.0 license.

另附:禁止在 CSDN,bilibili 等国内平台使用该配置文件进行任何活动。 你只保有自己修改部分的权利。

nvim's People

Contributors

avimitin avatar ocfox avatar clo91eaf avatar towry avatar xzcxzcyy avatar nias26 avatar rcklos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.