Merge pull request 'Align MzansiVim to VS code setup' (#8) from lsp-update into main
Reviewed-on: #8
This commit was merged in pull request #8.
This commit is contained in:
26
README.md
26
README.md
@@ -66,9 +66,33 @@ The **Leader Key** is set to `Space`.
|
|||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| **Hover Docs** | `K` | Display documentation for the symbol under cursor. |
|
| **Hover Docs** | `K` | Display documentation for the symbol under cursor. |
|
||||||
| **Go to Definition**| `gd` | Jump to the source code of a function/variable. |
|
| **Go to Definition**| `gd` | Jump to the source code of a function/variable. |
|
||||||
|
| **Code Actions** | `<leader>ca` | Show available fixes or refactors. |
|
||||||
|
| **Align File** | `<leader>rn` | Auto align file. |
|
||||||
| **References** | `gr` | List all places where a symbol is used. |
|
| **References** | `gr` | List all places where a symbol is used. |
|
||||||
| **Rename** | `<leader>rn` | Rename all occurrences of the symbol. |
|
| **Rename** | `<leader>rn` | Rename all occurrences of the symbol. |
|
||||||
| **Code Actions** | `<leader>ca` | Show available fixes or refactors. |
|
|
||||||
|
### Diagnostics (Errors & Warnings)
|
||||||
|
| Action | Keybinding | Description |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| **Show Error** | `<leader>e` | Open a floating window with the full error under cursor. |
|
||||||
|
| **Next Error** | `]d` | Jump to the next diagnostic in the file. |
|
||||||
|
| **Previous Error** | `[d` | Jump to the previous diagnostic in the file. |
|
||||||
|
| **Quickfix List** | `<leader>q` | Load all diagnostics into the quickfix list. |
|
||||||
|
| **Close Quickfix** | `:q <Enter>` | Close the quickfix window. |
|
||||||
|
|
||||||
|
### Window Management
|
||||||
|
| Action | Keybinding | Description |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| **Cycle Windows** | `Ctrl + w + w` | Cycle focus between open windows (e.g. quickfix ↔ code). |
|
||||||
|
| **Move Down** | `Ctrl + w + j` | Move focus to the window below. |
|
||||||
|
| **Move Up** | `Ctrl + w + k` | Move focus to the window above. |
|
||||||
|
| **Jump & Stay** | `Ctrl + w + Enter` | Open quickfix entry in a split, keeping quickfix focused. |
|
||||||
|
|
||||||
|
### Commenting
|
||||||
|
| Action | Keybinding | Description |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| **Toggle Comment** | `Ctrl + /` | Comment or uncomment the current line (normal mode). |
|
||||||
|
| **Toggle Comment** | `Ctrl + /` | Comment or uncomment the selection (visual mode). |
|
||||||
|
|
||||||
### Editor Essentials
|
### Editor Essentials
|
||||||
| Action | Keybinding | Description |
|
| Action | Keybinding | Description |
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
|
||||||
"LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" },
|
"LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" },
|
||||||
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
|
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
|
||||||
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||||
|
"dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" },
|
||||||
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
|
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
|
||||||
"flutter-tools.nvim": { "branch": "main", "commit": "677cc07c16e8b89999108d2ebeefcfc5f539b73c" },
|
"flutter-tools.nvim": { "branch": "main", "commit": "677cc07c16e8b89999108d2ebeefcfc5f539b73c" },
|
||||||
"harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" },
|
"harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" },
|
||||||
@@ -16,7 +18,6 @@
|
|||||||
"nvim-treesitter": { "branch": "main", "commit": "2cc172c28e5550e00e6beead4599b1469469c1c7" },
|
"nvim-treesitter": { "branch": "main", "commit": "2cc172c28e5550e00e6beead4599b1469469c1c7" },
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
|
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
"snacks.nvim": { "branch": "main", "commit": "a049339328e2599ad6e85a69fa034ac501e921b2" },
|
|
||||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
|
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" },
|
"telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" },
|
||||||
"tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" },
|
"tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" },
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ return {
|
|||||||
|
|
||||||
local mason_lspconfig = require("mason-lspconfig")
|
local mason_lspconfig = require("mason-lspconfig")
|
||||||
-- We no longer need: local lspconfig = require("lspconfig")
|
-- We no longer need: local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
local servers = {
|
local servers = {
|
||||||
@@ -51,70 +50,96 @@ return {
|
|||||||
vim.lsp.enable(server_name)
|
vim.lsp.enable(server_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Diagnostic display config
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = true, -- show error inline at end of line
|
||||||
|
signs = true,
|
||||||
|
underline = true,
|
||||||
|
update_in_insert = false, -- only update after leaving insert mode
|
||||||
|
float = {
|
||||||
|
border = "rounded",
|
||||||
|
source = true, -- shows which LSP reported the error
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
-- Keybindings (unchanged)
|
-- Keybindings (unchanged)
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
local opts = { buffer = ev.buf }
|
local opts = { buffer = ev.buf }
|
||||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||||
end,
|
-- Diagnostic keymaps
|
||||||
|
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts) -- show error under cursor
|
||||||
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous error
|
||||||
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next error
|
||||||
|
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts) -- all errors in quickfix list
|
||||||
|
vim.keymap.set("n", "<leader>af", vim.lsp.buf.format, { desc = "Format file" }) -- manual format
|
||||||
|
|
||||||
|
-- Format on save
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
buffer = ev.buf,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format({ async = false })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nvim-flutter/flutter-tools.nvim",
|
"nvim-flutter/flutter-tools.nvim",
|
||||||
lazy = false, -- Load on startup to ensure it handles dartls correctly
|
lazy = false, -- Load on startup to ensure it handles dartls correctly
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
"stevearc/dressing.nvim", -- Optional but highly recommended for better UI
|
"stevearc/dressing.nvim", -- Optional but highly recommended for better UI
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
require("flutter-tools").setup({
|
|
||||||
lsp = {
|
|
||||||
-- Pass your existing capabilities to the flutter-tools LSP config
|
|
||||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
|
||||||
-- You can add specific dartls settings here if needed
|
|
||||||
settings = {
|
|
||||||
showTodos = true,
|
|
||||||
completeFunctionCalls = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
{
|
config = function()
|
||||||
"hrsh7th/nvim-cmp",
|
require("flutter-tools").setup({
|
||||||
dependencies = {
|
lsp = {
|
||||||
|
-- Pass your existing capabilities to the flutter-tools LSP config
|
||||||
|
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||||
|
-- You can add specific dartls settings here if needed
|
||||||
|
settings = {
|
||||||
|
showTodos = true,
|
||||||
|
completeFunctionCalls = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
"hrsh7th/cmp-buffer",
|
"hrsh7th/cmp-buffer",
|
||||||
"hrsh7th/cmp-path",
|
"hrsh7th/cmp-path",
|
||||||
"L3MON4D3/LuaSnip", -- Snippet engine is usually required by cmp configs
|
"L3MON4D3/LuaSnip", -- Snippet engine is usually required by cmp configs
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require("luasnip").lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = "nvim_lsp" },
|
{ name = "nvim_lsp" },
|
||||||
{ name = "luasnip" },
|
{ name = "luasnip" },
|
||||||
}, {
|
}, {
|
||||||
{ name = "buffer" },
|
{ name = "buffer" },
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
-- Git Plugin
|
-- Git Plugin
|
||||||
'tpope/vim-fugitive',
|
'tpope/vim-fugitive',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"numToStr/Comment.nvim",
|
||||||
|
config = function()
|
||||||
|
require("Comment").setup()
|
||||||
|
vim.keymap.set("n", "<C-/>", "gcc", { remap = true, desc = "Toggle comment" })
|
||||||
|
vim.keymap.set("v", "<C-/>", "gc", { remap = true, desc = "Toggle comment" })
|
||||||
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user