Vscode-Neovim Support

- NeoVIM: Updates to NOT certain plugins in VSCode
- NeoVIM: Keymaps loaded only when neovim and NOT for VSCode
- VSCode: Added NeoVIM plugin with corresponding settings
This commit is contained in:
Pratik Tripathy
2024-07-01 22:08:08 +05:30
parent 98578abf18
commit 4c5aa8ff03
15 changed files with 81 additions and 17 deletions

View File

@@ -22,6 +22,7 @@
"editor.insertSpaces": true, "editor.insertSpaces": true,
"editor.detectIndentation": false, "editor.detectIndentation": false,
"editor.multiCursorModifier": "ctrlCmd", "editor.multiCursorModifier": "ctrlCmd",
"editor.cursorSurroundingLines": 8,
"files.trimTrailingWhitespace": true, "files.trimTrailingWhitespace": true,
"files.autoSave": "afterDelay", "files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000, "files.autoSaveDelay": 1000,
@@ -52,13 +53,23 @@
"debug.onTaskErrors": "debugAnyway", "debug.onTaskErrors": "debugAnyway",
// NeoVIM // NeoVIM
// "keyboard.dispatch": "keyCode", // Hack to make CAPS->Esc remap work on Ubuntu "keyboard.dispatch": "keyCode", // Hack to make CAPS->Esc remap work on Ubuntu
// "extensions.experimental.affinity": { "extensions.experimental.affinity": {
// "asvetliakov.vscode-neovim": 1 "asvetliakov.vscode-neovim": 1
// }, },
// "vscode-neovim.logLevel": "warn",
// "vscode-neovim.neovimExecutablePaths.linux": "/home/linuxbrew/.linuxbrew/bin/nvim", // "vscode-neovim.neovimExecutablePaths.linux": "/home/linuxbrew/.linuxbrew/bin/nvim",
// "vscode-neovim.useWSL": true, // "vscode-neovim.useWSL": true,
// https://github.com/vscode-neovim/vscode-neovim/wiki/Settings#search-result-border
"vscode-neovim.highlightGroups.highlights": {
"IncSearch": {
"borderStyle": "solid",
"borderWidth": "1px"
},
"Search": {
"borderStyle": "solid",
"borderWidth": "1px"
}
},
// //
// Prettier Plugin // Prettier Plugin

View File

@@ -1,6 +1,7 @@
-- Load Keybindings from VIM -- Load Keybindings from VIM
local vim_mappings = os.getenv("HOME") .. "/.vim/key_maps.vim" local vim_mappings = os.getenv("HOME") .. "/.vim/key_maps.vim"
if vim.loop.fs_stat(vim_mappings) then local util = require("config.util")
if vim.loop.fs_stat(vim_mappings) and util.is_not_vscode() then
vim.cmd("source " .. vim_mappings) vim.cmd("source " .. vim_mappings)
end end
@@ -43,8 +44,10 @@ vim.keymap.set("i", ";", ";<C-g>u", { desc = "Auto add undo breakpoints on ';'"
vim.keymap.set("i", "\r", "\r<C-g>u", { desc = "Auto add undo breakpoints on new lines" }) vim.keymap.set("i", "\r", "\r<C-g>u", { desc = "Auto add undo breakpoints on new lines" })
-- Traverse Buffer -- Traverse Buffer
vim.keymap.set("n", "<Tab>", "<cmd>bnext<CR>", { desc = "Switch to next buffer" }) if require("config.util").is_not_vscode() then
vim.keymap.set("n", "<S-Tab>", "<cmd>bprevious<CR>", { desc = "Switch to previous buffer" }) vim.keymap.set("n", "<Tab>", "<cmd>bnext<CR>", { desc = "Switch to next buffer" })
vim.keymap.set("n", "<S-Tab>", "<cmd>bprevious<CR>", { desc = "Switch to previous buffer" })
end
-- Save file -- Save file
vim.keymap.set({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save file" }) vim.keymap.set({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save file" })

View File

@@ -98,6 +98,10 @@ local M = {
}, },
} }
function M.is_not_vscode()
return not vim.g.vscode
end
function M.fg(name) function M.fg(name)
---@type {foreground?:number}? ---@type {foreground?:number}?
---@diagnostic disable-next-line: deprecated ---@diagnostic disable-next-line: deprecated

View File

@@ -5,6 +5,7 @@ return {
{ {
-- Autocompletion -- Autocompletion
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
-- Snippet Engine & its associated nvim-cmp source -- Snippet Engine & its associated nvim-cmp source
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
@@ -76,6 +77,7 @@ return {
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
cond = require("config.util").is_not_vscode(),
keys = { keys = {
{ {
"<tab>", "<tab>",

View File

@@ -5,6 +5,7 @@ end
return { return {
{ {
"tpope/vim-dadbod", "tpope/vim-dadbod",
cond = require("config.util").is_not_vscode(),
opt = true, opt = true,
dependencies = { dependencies = {
{ "kristijanhusak/vim-dadbod-ui" }, { "kristijanhusak/vim-dadbod-ui" },

View File

@@ -3,6 +3,7 @@
return { return {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
-- Creates a beautiful debugger UI -- Creates a beautiful debugger UI
"rcarriga/nvim-dap-ui", "rcarriga/nvim-dap-ui",

View File

@@ -1,6 +1,7 @@
return { return {
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
-- cond = require("config.util").is_not_vscode(),
lazy = true, lazy = true,
event = { "BufReadPre", "BufNewFile" }, event = { "BufReadPre", "BufNewFile" },
config = function() config = function()

View File

@@ -14,6 +14,7 @@ return {
-- "gc" to comment visual regions/lines -- "gc" to comment visual regions/lines
{ {
"numToStr/Comment.nvim", "numToStr/Comment.nvim",
cond = require("config.util").is_not_vscode(),
config = function() config = function()
require("Comment").setup({ require("Comment").setup({
pre_hook = function() pre_hook = function()
@@ -26,6 +27,7 @@ return {
-- Better code folding -- Better code folding
{ {
"kevinhwang91/nvim-ufo", "kevinhwang91/nvim-ufo",
cond = require("config.util").is_not_vscode(),
event = "VeryLazy", event = "VeryLazy",
dependencies = { dependencies = {
"kevinhwang91/promise-async", "kevinhwang91/promise-async",
@@ -114,6 +116,7 @@ return {
-- indent guides for Neovim -- indent guides for Neovim
{ {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
cond = require("config.util").is_not_vscode(),
opts = { opts = {
indent = { char = "", tab_char = "" }, indent = { char = "", tab_char = "" },
scope = { enabled = false }, scope = { enabled = false },
@@ -139,6 +142,7 @@ return {
-- Highlights the current level of indentation, and animates the highlighting. -- Highlights the current level of indentation, and animates the highlighting.
{ {
"echasnovski/mini.indentscope", "echasnovski/mini.indentscope",
cond = require("config.util").is_not_vscode(),
opts = { symbol = "", options = { try_as_border = true } }, opts = { symbol = "", options = { try_as_border = true } },
init = function() init = function()
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
@@ -281,6 +285,7 @@ return {
-- Inlay hints -- Inlay hints
{ {
"lvimuser/lsp-inlayhints.nvim", "lvimuser/lsp-inlayhints.nvim",
cond = require("config.util").is_not_vscode(),
config = function() config = function()
require("lsp-inlayhints").setup() require("lsp-inlayhints").setup()
@@ -304,6 +309,7 @@ return {
-- LspSaga -- LspSaga
{ {
"nvimdev/lspsaga.nvim", "nvimdev/lspsaga.nvim",
cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
@@ -412,6 +418,7 @@ return {
-- Refactor code: Refactoring book by Martin Fowler -- Refactor code: Refactoring book by Martin Fowler
{ {
"ThePrimeagen/refactoring.nvim", "ThePrimeagen/refactoring.nvim",
cond = require("config.util").is_not_vscode(),
event = { "BufReadPre", "BufNewFile" }, event = { "BufReadPre", "BufNewFile" },
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",

View File

@@ -2,6 +2,7 @@ return {
-- Better fugitive: neogit -- Better fugitive: neogit
{ {
"NeogitOrg/neogit", "NeogitOrg/neogit",
cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"sindrets/diffview.nvim", "sindrets/diffview.nvim",
@@ -30,6 +31,7 @@ return {
-- Adds git related signs to the gutter, as well as utilities for managing changes -- Adds git related signs to the gutter, as well as utilities for managing changes
{ {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
cond = require("config.util").is_not_vscode(),
opts = { opts = {
-- See `:help gitsigns.txt` -- See `:help gitsigns.txt`
signs = { signs = {
@@ -109,6 +111,7 @@ return {
-- Git worktree -- Git worktree
{ {
"ThePrimeagen/git-worktree.nvim", "ThePrimeagen/git-worktree.nvim",
cond = require("config.util").is_not_vscode(),
config = function() config = function()
-- FIX: Open files do NOT get replaced with the changed branch -- FIX: Open files do NOT get replaced with the changed branch
require("telescope").load_extension("git_worktree") require("telescope").load_extension("git_worktree")

View File

@@ -33,6 +33,7 @@ return {
{ {
-- LSP Configuration & Plugins -- LSP Configuration & Plugins
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
-- Automatically install LSPs to stdpath for neovim -- Automatically install LSPs to stdpath for neovim
{ "williamboman/mason.nvim", config = true }, { "williamboman/mason.nvim", config = true },
@@ -46,6 +47,7 @@ return {
{ {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
cond = require("config.util").is_not_vscode(),
config = function() config = function()
-- Configure LSP -- Configure LSP
@@ -64,6 +66,7 @@ return {
workspace = { checkThirdParty = false }, workspace = { checkThirdParty = false },
telemetry = { enable = false }, telemetry = { enable = false },
completion = { callSnippet = "Replace" }, completion = { callSnippet = "Replace" },
hint = { enable = true },
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } }, -- diagnostics = { disable = { 'missing-fields' } },
}, },
@@ -95,7 +98,7 @@ return {
}, },
typescript = { typescript = {
inlayHints = { inlayHints = {
-- includeInlayParameterNameHints = 'all', includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false, includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true, includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true, includeInlayVariableTypeHints = true,
@@ -107,7 +110,7 @@ return {
}, },
javascript = { javascript = {
inlayHints = { inlayHints = {
-- includeInlayParameterNameHints = 'all', includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false, includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true, includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true, includeInlayVariableTypeHints = true,
@@ -173,6 +176,7 @@ return {
{ {
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
cond = require("config.util").is_not_vscode(),
opts = { opts = {
progress = { progress = {
poll_rate = 1, -- How and when to poll for progress messages poll_rate = 1, -- How and when to poll for progress messages

View File

@@ -3,11 +3,12 @@ return {
-- Taken from LazyVim -- Taken from LazyVim
{ {
"nvim-neotest/neotest", "nvim-neotest/neotest",
cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim", "antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
"marilari88/neotest-vitest" "marilari88/neotest-vitest",
}, },
opts = { opts = {
-- Do NOT add adapters here -- Do NOT add adapters here
@@ -31,8 +32,7 @@ return {
virtual_text = { virtual_text = {
format = function(diagnostic) format = function(diagnostic)
-- Replace newline and tab characters with space for more compact diagnostics -- Replace newline and tab characters with space for more compact diagnostics
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
"")
return message return message
end, end,
}, },

View File

@@ -114,6 +114,7 @@ return {
-- File Explorer: Neotree -- File Explorer: Neotree
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
cond = require("config.util").is_not_vscode(),
branch = "v3.x", branch = "v3.x",
keys = { keys = {
{ "<leader>e", "<CMD>Neotree filesystem toggle<CR>", desc = "Open NeoTree Explorer at Git root", remap = true }, { "<leader>e", "<CMD>Neotree filesystem toggle<CR>", desc = "Open NeoTree Explorer at Git root", remap = true },
@@ -206,6 +207,7 @@ return {
-- Telescope: Fuzzy Finder (files, lsp, etc) -- Telescope: Fuzzy Finder (files, lsp, etc)
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
cond = require("config.util").is_not_vscode(),
branch = "0.1.x", branch = "0.1.x",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",

View File

@@ -1,18 +1,28 @@
return { return {
-- icons -- icons
{ "nvim-tree/nvim-web-devicons" }, {
"nvim-tree/nvim-web-devicons",
cond = require("config.util").is_not_vscode(),
},
-- ui components -- ui components
{ "MunifTanjim/nui.nvim" }, {
"MunifTanjim/nui.nvim",
cond = require("config.util").is_not_vscode(),
},
-- Better vim.ui -- Better vim.ui
{ "stevearc/dressing.nvim" }, {
"stevearc/dressing.nvim",
cond = require("config.util").is_not_vscode(),
},
{ "machakann/vim-highlightedyank" }, { "machakann/vim-highlightedyank" },
-- colorscheme -- colorscheme
{ {
"projekt0n/github-nvim-theme", "projekt0n/github-nvim-theme",
cond = require("config.util").is_not_vscode(),
lazy = false, lazy = false,
priority = 1000, priority = 1000,
config = function() config = function()
@@ -23,6 +33,7 @@ return {
-- Show buffers like VS Code tabs -- Show buffers like VS Code tabs
{ {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
cond = require("config.util").is_not_vscode(),
dependencies = { dependencies = {
{ "echasnovski/mini.bufremove", version = "*" }, { "echasnovski/mini.bufremove", version = "*" },
}, },
@@ -72,6 +83,7 @@ return {
-- Better `vim.notify()` -- Better `vim.notify()`
{ {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
cond = require("config.util").is_not_vscode(),
keys = { keys = {
{ {
"<leader>xn", "<leader>xn",
@@ -106,6 +118,7 @@ return {
-- Completely replaces the UI for messages, cmdline and the popupmenu. -- Completely replaces the UI for messages, cmdline and the popupmenu.
{ {
"folke/noice.nvim", "folke/noice.nvim",
cond = require("config.util").is_not_vscode(),
event = "VeryLazy", event = "VeryLazy",
dependencies = { dependencies = {
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
@@ -177,6 +190,7 @@ return {
-- Set lualine as statusline -- Set lualine as statusline
{ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
cond = require("config.util").is_not_vscode(),
init = function() init = function()
vim.g.lualine_laststatus = vim.o.laststatus vim.g.lualine_laststatus = vim.o.laststatus
if vim.fn.argc(-1) > 0 then if vim.fn.argc(-1) > 0 then

View File

@@ -176,11 +176,15 @@ return {
}, },
-- Navigate between NVIM & Tmux splits seamlessly -- Navigate between NVIM & Tmux splits seamlessly
{ "christoomey/vim-tmux-navigator" }, {
"christoomey/vim-tmux-navigator",
cond = require("config.util").is_not_vscode(),
},
-- Navigate between NVIM & kitty splits -- Navigate between NVIM & kitty splits
{ {
"knubie/vim-kitty-navigator", "knubie/vim-kitty-navigator",
cond = require("config.util").is_not_vscode(),
build = "cp ./*.py ~/.config/kitty/", build = "cp ./*.py ~/.config/kitty/",
keys = { keys = {
{ "<C-S-h>", "<cmd>KittyNavigateLeft<cr>" }, { "<C-S-h>", "<cmd>KittyNavigateLeft<cr>" },
@@ -194,6 +198,7 @@ return {
{ {
"mikesmithgh/kitty-scrollback.nvim", "mikesmithgh/kitty-scrollback.nvim",
lazy = true, lazy = true,
cond = require("config.util").is_not_vscode(),
cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" }, cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
event = { "User KittyScrollbackLaunch" }, event = { "User KittyScrollbackLaunch" },
version = "^4.0.0", version = "^4.0.0",
@@ -210,6 +215,7 @@ return {
-- Changes the Nvim root to git root -- Changes the Nvim root to git root
{ {
"airblade/vim-rooter", "airblade/vim-rooter",
cond = require("config.util").is_not_vscode(),
config = function() config = function()
vim.g.rooter_cd_cmd = "tcd" -- Use tcd command to change the root vim.g.rooter_cd_cmd = "tcd" -- Use tcd command to change the root
end, end,
@@ -265,6 +271,7 @@ return {
-- Speedup loading large files by disabling some plugins -- Speedup loading large files by disabling some plugins
{ {
"LunarVim/bigfile.nvim", "LunarVim/bigfile.nvim",
cond = require("config.util").is_not_vscode(),
lazy = true, lazy = true,
opts = { opts = {
filesize = 2, --2MiB filesize = 2, --2MiB

View File

@@ -7,3 +7,7 @@ let g:NERDTreeWinSize = 25
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
let g:qs_accepted_chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] let g:qs_accepted_chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
" Quickscope in VSCode
" https://github.com/vscode-neovim/vscode-neovim/wiki/Plugins#quick-scope
highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline