Coder Social home page Coder Social logo

knvim's Introduction

KNVIM

Neovim Lua

K-nvim or kn-vim, personal attempt to config Neovim and a pun on my username knmac.

1. Demo

Video demo with clickable lualine: demo3

Config structure and cheatsheet (rendered): demo1

Editing a python file, with LSP, Tree-sitter, and outline support: demo2

2. Feature highlights

  • Targeting python, bash, latex, markdown, and (some) C/C++ usage.
  • Lualine is configured to be (mostly) clickable. (Toggle with the command :ToggleClickableLualine).
  • Key-bindings that (hopefully) make sense.
  • Fun (for me) to use!!!

3. Content

3.1. Configured servers

Language Name Category
Python pyright LSP
ruff_lsp Linter/Formatter
debugpy DAP
Bash bashls LSP
shellcheck Linter
C/C++ clangd LSP
cpplint Linter
codelldb DAP
Vimscript vim_ls LSP
Lua lua_ls LSP
LaTex texlab LSP
Markdown marksman LSP
prettier LSP
YAML yamlls LSP
prettier Formatter
Typescript/Javascript tsserver LSP
prettier Formatter
HTML/CSS/Json prettier Formatter

3.2. Config structure

init.lua
lua/
├── core/
│  ├── auto_commands.lua
│  ├── init.lua
│  ├── keymaps.lua
│  └── settings.lua
└── plugins/
   ├── coding/
   │  ├── cmp.lua
   │  ├── dap.lua
   │  ├── linter-formatter.lua
   │  ├── lspconfig-mason.lua
   │  ├── metals.lua
   │  ├── neotest.lua
   │  └── treesitter.lua
   ├── experimentals/
   │  └── ...
   ├── ui/
   │  ├── alpha.lua
   │  ├── barbar.lua
   │  ├── catppuccin.lua
   │  ├── fold.lua
   │  ├── illuminate.lua
   │  ├── indentblankline-rainbow.lua
   │  ├── lualine.lua
   │  ├── navic-barbecue.lua
   │  ├── noice-notify.lua
   │  └── winsep.lua
   ├── utils/
   │  ├── diffview.lua
   │  ├── easy-align.lua
   │  ├── gitsigns.lua
   │  ├── leap.lua
   │  ├── matchup.lua
   │  ├── neo-tree.lua
   │  ├── nvim-colorizer.lua
   │  ├── obsidian.lua
   │  ├── swenv.lua
   │  ├── outline.lua
   │  ├── remote-nvim.lua
   │  ├── telescope.lua
   │  ├── todo-comments.lua
   │  ├── toggleterm.lua
   │  ├── which-key.lua
   │  ├── yazi.lua
   │  └── zen-mode.lua
   └── init.lua

The configs in experimentals/ directories are not activated by default. To use them, uncomment the following line in lua/plugins/init.lua:

{ import = "plugins.experimentals", },

If you want to try individual experimental plugins instead of the all of them, uncomment a specific plugins, e.g.,

{ import = "plugins.experimentals.neorg", },
{ import = "plugins.experimentals.remote-nvim", },

4. Manual installation

4.1. Dependencies

The following dependencies are for manual installation.

  • Neovim 0.10.0+. Follow the installation guide on Neovim's homepage. This repo is just holding the config.
  • A nerdfont for the glyphs and a terminal that supports the font (the screenshots use WezTerm and its baked-in JetBrains Mono font).
  • npm for mason.nvim (package manager for LSPs, DAPs, linters, and formaters).
  • rg and fd for telescope.nvim (fuzzy finder).
  • (Optional) Python packages pynvim, neovim, and pylatexenc (installable with pip).
  • (Optional) Yazi for file browser.
  • (Optional) LazyGit for quick git management from ToggleTerm.

4.2. Installation

Clone this repo to $HOME/.config:

git clone https://github.com/knmac/knvim.git $HOME/.config/knvim

Then add this command to .bashrc or .zshrc.

export NVIM_APPNAME="knvim"

4.3. Removing knvim

Simply delete the two directories $HOME/.config/knvim and $HOME/.local/share/knvim.

5. Installation using nvim-lazyman

Nvim-lazyman is a configuration manager that supports popular Neovim configurations. After installing nvim-lazyman, run the following command to install knvim:

lazyman -L Knvim

Follow instructions from nvim-lazyman for details about installation, bootstrapping, and other cool features.

6. Knvim Cheatsheet

Cheatsheet for knvim can be found here. You can also access cheatsheet from the start page.

7. Extra configs (optional)

This section shows you how to set up extra configuration for knvim to work as you want (completely optional).

7.1. Ruff (Python linter) and Black (Python formater)

Create the file pyproject.toml for each Python project, where the content looks something like this:

[tool.ruff]
line-length = 110

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
select = ["E", "F"]
# Avoid enforcing line-length violations (`E501`)
ignore = ["E501"]

[tool.ruff.format]
# Use double quotes for strings.
quote-style = "double"
# Indent with spaces, rather than tabs.
indent-style = "space"

For more information, visit here and here.

7.2. DAP (Debugging tool)

Create the file .vscode/launch.json for each project, where the content looks something like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "python",
      "request": "launch",
      "name": "NAME OF THE LAUNCH",
      "program": "${file}",
      "console": "integratedTerminal",
      "args": ["ARG1", "ARG2", ...]
    }
  ]
}

The above config uses Python as an example, but you can setup debugger for other languages similarly. The template for Python launcher can be generated with ,g. For more information, visit here.

7.3. Diffview (Intergate Diffview to git mergetool automatically)

Create the file ~/.gitconfig globally, where the content looks something like this:

[merge]
    tool = nvim
[mergetool]
    keepBackup = false
    prompt = false
[mergetool "nvim"]
    cmd = "nvim -d -c \"wincmd l\" -c \"norm ]c\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\" -c DiffviewOpen"

7.4. Marksman (LSP server for markdown)

Create the file .marksman.toml for each project, where the (default) content looks something like this:

[core]
markdown.file_extensions = ["md", "markdown"]
text_sync = "full"
incremental_references = false
paranoid = false

[code_action]
toc.enable = true
create_missing_file.enable = true

[completion]
wiki.style = "title-slug"

8. FAQs

Q1: Why knvim is not working on Windows?

A1: knvim config targets Unix-based OS (e.g., Linux and MacOS) and is not fully tested on Windows. Some common problems include different path separator (/ on Unix vs \ on Windows) and EOL character (LF on Unix and CR LF on Windows). You may want to change these characters manually if you want to try knvim on Windows machines.

Q2: Why knvim does not include <this and that> by default?

A2: knvim is my personal config of Neovim, so it does not cover a wide range of different use cases. You are more than welcome (and recommended) to fork and customize knvim to your personal liking. That said, I will try to add some configs if they are commonly used. Cheers!

Q3: Why knvim does not render <this and that>?

A3: This is mostly how the terminal is configured. Here are some example use-cases (tested on Wezterm). Please inspect the code carefully before running.

  • Rendering undercurl ref:
tempfile=$(mktemp) \
  && curl -o "$tempfile https://raw.githubusercontent.com/wez/wezterm/master/termwiz/data/wezterm.terminfo" \
  && tic -x -o ~/.terminfo "$tempfile" \
  && rm "$tempfile"
  • Rendering strikethrough ref:
infocmp "$TERM" > myterm.info
nvim myterm.info # add smxx=\E[9m, rmxx=\E[29m,
tic -x myterm.info

9. TODO

  • Automatically copy knvim to server for remote editing.
  • Image rendering (may only support Kitty and WezTerm terminal). You can try the experimental config plugins.experimental.image.
  • Automatically switch path separator and EOL character, depending on the OS in use.
  • Support python environment manager poetry.

knvim's People

Contributors

knmac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

troflog bquocminh

knvim's Issues

feature request - add pyenv managed python

Thank you for great neovim configuration, would like to ask - if it possible to add a pyenv python to the list of searched python providers ?
Like os.getenv('HOME') .. '/.pyenv/shims/python' - in my opinion, the pyenv managed python installation are quite popular.

Regards

Maxim

Treesitter dap_repl parser install

I am currently seeing an error during initialization of knvim with:

   Error  04:14:49 PM notify.error lazy.nvim Failed to run `config` for nvim-treesitter
vim/_meta.lua:0: Vim:Installation not possible: ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/install.lua:86: Parser not available for language "dap_repl"

I think what is happening is the nvim-dap-repl-highlights plugin is not getting loaded as it is a dependency of a plugin that is VeryLazy. Or, maybe it just needs to be configured differently.

The nvim-dap-repl-highlights README has the following note:

NOTE: If you use the ensure_installed option you must first setup nvim-dap-repl-highlights
or else the dap_repl parser won't be found, for example
require('nvim-dap-repl-highlights').setup()
require('nvim-treesitter.configs').setup {
  highlight = {
    enable = true,
  },
  ensure_installed = { 'dap_repl', ... },
  ...
}

Knvim in the Lazyman Neovim Configuration Manager

I've created a Neovim Configuration Manager that supports easy installation and initialization of multiple Neovim configurations using the NVIM_APPNAME environment variable in Neovim 0.9. I call it Lazyman and include support for Knvim as one of the "Personal" Neovim configurations installed and initialized by lazyman.

See https://github.com/doctorfree/nvim-lazyman for info on Lazyman.

I'm contacting the maintainers of the Lazyman supported Neovim configurations to seek any feedback on the description, installation, and initialization of their config in Lazyman. Please feel free to let me know what I'm doing wrong or how I could improve the incorporation of Knvim in Lazyman. If you feel there is a need to modify the way Knvim is used in Lazyman then open an issue at https://github.com/doctorfree/nvim-lazyman/issues

This isn't really an issue with Knvim, it is just a heads up and request for feedback.

Knvim is very cool. Thanks!

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.