Skip to content

genzj/mynvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My NeoVim Configurations

Usage

  1. Clone this repo to replace your ~/.config/nvim/ folder:

    mv ~/.config/nvim/ ~/.config/nvim.backup
    git clone https://github.com/genzj/mynvim.git ~/.config/nvim
  2. Install Python dependencies:

    1. Install mise
    2. Create the virtualenv and install dependencies into it by:
      cd ~/.config/nvim/
      mise install [email protected]
      python -m venv ~/.venvs/nvim
      which pip  # make sure the output shows a path to virtualenv, e.g. ~/.venvs/nvim/bin/pip
      pip install -U -r requirements.txt
    3. Alternatively, a Python 3.11+ virtualenv can be created in any of the following path with any other methods. configs/python.lua will search for virtualenv in the same order:
      • $WORKON_HOME/nvim/
      • ~/.venvs/nvim/
      • $PYENV_ROOT/versions/nvim
  3. Create the init file ~/.config/nvim/init.vim with following content:

    lua require("mynvim")
  4. (Windows) Install LLVM by following this wiki then setting it in the beginning of the init.vim, e.g.:

     lua <<EOF
     vim.env.PATH = vim.env.PATH .. ";D:\\code\\LLVM\\bin"
     vim.g.mynvim_install = {
         treesitter = {
             "rust",
         },
    
         servers = {
             ["rust_analyzer"] = {},
         }
     }
     EOF
  5. (Optional) if this repo is cloned to a different folder, the path should be added to runtimepath, e.g.:

     set runtimepath+=e:/proj/mynvim
     lua require("mynvim")
  6. Install ripgrep for enhanced grep and substitution experience.

  7. Run nvim and Lazy should install all plugins automatically.

  8. After Lazy finishes its work, quit and reopen NVIM to make sure all plugins are loaded.

Customization

Add language supports

To add per-host config for languages, edit the ~/.config/nvim/init.vim to set g:mynvim_install to extend the mynvim.configs.install table. Run vim command :ShowInstallConfig to inspect the final config.

E.g.:

lua <<EOF
vim.g.mynvim_install = {
    -- optional presets, read "mynvim.configs.install" variable "blends" for
    -- details
    blends = {
        "rust",
        "python",
    },
    treesitter = {
        "fish",
        "rust",
    },

    -- Install non-lsp extentions, such as null-ls dependencies.
    -- For lsp-config supported servers, check the `servers` key below.
    -- Package list: https://mason-registry.dev/registry/list
    mason = {
    },

    nls = {
        -- "nls." or "null_ls." (recommended) prefixed items will be loaded
        -- from the null-ls package
        -- https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTINS.md
        "null_ls.builtins.formatting.stylua",

        -- "package.subpackage:a.b.c" is equivalent to
        -- require("package.subpackage").a.b.c

        -- the ":" can be ommitted if the default object is desired, i.e.
        -- "package.subpackage" is equivalent to "package.subpackage:" and
        -- require("package.subpackage")
    },

    -- LSP server configs. Configured servers will be installed by mason-lspconfig
    -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
    -- https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
    servers = {
        ["rust_analyzer"] = {},
    }
}
EOF

lua require("mynvimrc.lua")

Ref:

Override Options

Some options are set in the VeryLazy user event callbacks so directly change them from init.vim may not work as expected. A more reliable solution is registering autocmds for the same event and override options there, e.g.

augroup CustomOptionSetup
    au!
    au User VeryLazy let &guifont="Hack_Nerd_Font:h13.000000,".&guifont
augroup END

lua require("mynvim")

About

My NeoVim config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •