Skip to content

x10-config/neovide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust IDE with Neovide for Lazy Vim Users

Better workflow , testing and debugging capability on your Next Rust Projects

Screenshot 2024-07-28 at 5 11 02 PM

NOTE: Only MacOS Keymaps Are Well Documented on this README.md , I have remove all examples for windows/linux.

NOTE: At the moment , only MacOS have been tested and perfected for the workflow. You can Fork and Submit Pull Request If you wanted your Contribution to be added on Main Branch.

Installation on Macos and Linux
git clone https://github.com/codeitlikemiley/nvim
mv nvim ~/.config
cd nvim ~/.config/nvim
chmod +x ./install.sh

Please Check ./install.sh before running it , especially if your on linux , your package manager might not be supported by the script

Requirements

Must Have Installed, check the link on how to install it

Warning: if you have existing neovim set up check this out


Note: if you forget keybindings just press SHIFT + SPACE

Override Cargo Run/Test with Makefile

Any Commands that extends Cargo e.g. cargo-watch , cargo-leptos or dioxus-cli can be forced to be used instead of cargo run or cargo test commands using a Makefile

Example Makefile for Running Cargo Leptos
# Makefile for a Rust project using cargo-leptos and cargo-nextest

# Default target
.PHONY: all
all: build

# Build target
.PHONY: build
build:
	cargo leptos build

.PHONY: run
run:
	cargo leptos watch

# Test target
.PHONY: test
test:
	cargo nextest run

# Clean up
.PHONY: clean
clean:
	cargo clean

Defining Debugger Configurations

The DAP Configuration can be added on Root Folder of your project with a name .dap_config , you can place any .lua file here but it is important to remember the Naming Convention if you wanna add configuration for rust then name the file rust.lua

If you have created .dap_config folder with rust.lua inside it would load that dap configuration

Example Dap Configuration for Rust
local function get_configurations()
    return {
        {
            type = 'codelldb',
            request = 'launch',
            name = "Debug executable 'server'",
            cargo = {
                args = {
                    "build",
                    "--bin=server",
                    "--package=server"
                },
                filter = {
                    name = "server",
                    kind = "bin"
                }
            },
            args = {},
            cwd = '${workspaceFolder}',
            program = function()
                return vim.fn.getcwd() .. '/target/debug/server'
            end,
        },
        -- Add other configurations here...
    }
end

return get_configurations
Ultimate Productivity Keybindings

Show All Keymaps

SHIFT+SPACE === List and Search All Keymaps

Note: For Mac CMD for Windows/Linux replace it with ALT for different keymaps it is listed below

Testing:

F1 === RustRunnables

F3 === RustDebuggables

F4 === Rust Parent Module

F5 === Reload Workspace

-- Mac Only

CMD + R === Smart Cargo Run and Test

CMD + D === Debug Test Under Cursor (mac)

CMD + K === Debug Continue (mac)

Debugging:

CMD + backtick === Toggle Debugger UI

CMD + J === Step Over

CMD + L === Step Into

CMD + H === Step Out

OPT + S === Continue

F8 === Dap Terminate

CMD + I === Rust Toggle Inlay Hints

-- Mac Only CMD + B === Toggle Breakpoint (mac)

File Editing

F2 === Rename

CMD + S === Save

CMD + V === Paste

CMD + Z === Undo

CMD + . === Code Actions

CMD + M === Expand Rust Macro

CMD + slash === Comment Selected Lines on Visual / Normal Mode

slash + slash === Comment Line

Note: this is for MacOS users only

OPT + J,K === Move Line Up and Down

Navigation

Note: You need to Rebind CMD + Q to use Smart Quit (optional) , defaults to Quit Neovide

CMD + Q === Quit All

CMD + N === New Tab

CMD + Y === Rebuild Proc Macro

CMD + [1-9] === Switch Tab [1-9]

CMD + F1 === Toggle Sidebar

CMD + F2 === Neotest Summary

CMD + F3 === Diff View File

CMD + F4 === Diff Close View

CMD + F5 === Toggle Test Summary

CMD + F6 === Reload VimRC

Telescope

OPT + D === Diff View File History

CMD + F === Find Everything on Workspace

CMD + G === Open Lazy Git

OPT + D === Diff File History

CMD + O === Go to Symbols on Current Open File

CMD + T === Go to Workspace Symbols

CMD + P === Open Recent Files

CMD + E === Open Copilot Chat Actions


Some Built in Keybindings by Lazy Nvim

LSP

leader + uf === Toggle Formatting

Key Description Mode
gd Goto Definition n
gr References n
gD Goto Declaration n
gI Goto Implementation n
gy Goto T[y]pe Definition n
K Hover n
]d Next Diagnostic n
[d Prev Diagnostic n
]e Next Error n
[e Prev Error n
]w Next Warning n
[w Prev Warning n
<leader>cf Format Document n
<leader>ca Code Action n, v
<leader>cA Source Action n
<leader>cr Rename n

Jumping Around

Note: usage is press eg. f / F then the character to search eg: a then press any highligted 1 char to jump into

f === Jump to Char Forward

F === Jump to Char Backward

Note: you can use n to search forward and N to search backward

/ === Search for Characters

gw === Search Word under cursor

Checkout Built-in Snippets with Rust Click here to view the snippets

A

  • allow
  • assert
  • assert_eq

B

  • bench

C

  • cfg
  • cfg_attr
  • cfg!
  • column
  • concat
  • concat_idents
  • const

D

  • deny
  • debug_assert
  • debug_assert_eq
  • derive

E

  • env
  • extern-crate
  • extern-fn
  • extern-mod
  • else
  • enum
  • Err

F

  • file
  • format
  • format_args
  • fn
  • for

I

  • include
  • include_bytes
  • include_str
  • if-let
  • if
  • impl-trait
  • impl
  • inline-fn

L

  • line
  • loop
  • let

M

  • macro_use
  • module_path
  • main
  • match
  • mod
  • mod-block
  • macro_rules

N

  • no_std
  • no_core

O

  • option_env
  • Ok

P

  • panic
  • print
  • println
  • pfn

R

  • repr

S

  • stringify
  • static
  • Some
  • struct-tuple
  • struct-unit
  • struct

T

  • thread_local
  • try
  • test
  • trait
  • type

U

  • unimplemented
  • unreachable

V

  • vec

W

  • write
  • writeln
  • while-let
  • while
How to add custom snippets?
  1. Create a file in ~/.config/nvim/snippets/rust.snippets

mkdir -pv ~/.config/nvim/snippets && touch ~/.config/nvim/snippets/rust.snippets

  1. Edit ~/.config/nvim/lua/plugins/snip.lua
dependencies = {
    "rafamadriz/friendly-snippets",
    config = function()
      require("luasnip.loaders.from_vscode").load({
        include = { "rust" },
        -- Uncomment paths
        paths = {
         "~/.config/nvim/snippets"
        },
      })
    end,
  },
  1. Add your custom snippets in ~/.config/nvim/snippets/rust.snippets

Note: Format should be the same as vscode snippets eg. built-in-rust-snippets

As a reference on the structure of these snippet libraries, see friendly-snippets.

We support a small extension: snippets can contain LuaSnip-specific options in the luasnip-table:

"example1": {
	"prefix": "options",
	"body": [
		"whoa! :O"
	],
	"luasnip": {
		"priority": 2000,
		"autotrigger": true,
		"wordTrig": false
	}
}

Files with the extension jsonc will be parsed as jsonc, json with comments, while *.json are parsed with a regular json parser, where comments are disallowed. (the json-parser is a bit faster, so don't default to jsonc if it's not necessary).

Example:

~/.config/nvim/my_snippets/package.json:

{
	"name": "example-snippets",
	"contributes": {
		"snippets": [
			{
				"language": [
					"all"
				],
				"path": "./snippets/all.json"
			},
			{
				"language": [
					"lua"
				],
				"path": "./lua.json"
			}
		]
	}
}

~/.config/nvim/my_snippets/snippets/all.json:

{
	"snip1": {
		"prefix": "all1",
		"body": [
			"expands? jumps? $1 $2 !"
		]
	},
	"snip2": {
		"prefix": "all2",
		"body": [
			"multi $1",
			"line $2",
			"snippet$0"
		]
	}
}

~/.config/nvim/my_snippets/lua.json:

{
	"snip1": {
		"prefix": "lua",
		"body": [
			"lualualua"
		]
	}
}

This collection can be loaded with any of

-- don't pass any arguments, luasnip will find the collection because it is (probably) in rtp.

require("luasnip.loaders.from_vscode").lazy_load()

-- specify the full path...

 uarequire("luasnip.loaders.from_vscode").lazy_load({paths = "~/.config/nvim/my_snippets"})

-- or relative to the directory of $MYVIMRC

require("luasnip.loaders.from_vscode").load({paths = "./my_snippets"})

Standalone

For Quickly Adding Snippets please use my snip-cli

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published