fixed autocompletion and added some shit
This commit is contained in:
142
README.md
142
README.md
@@ -1,67 +1,89 @@
|
||||
🚀 GENERAL KEYBINDS:
|
||||
<leader>e - Show diagnostic float
|
||||
[d / ]d - Navigate diagnostics
|
||||
<leader>n - Toggle file explorer (Neo-tree)
|
||||
<leader>ff - Find files (Telescope)
|
||||
<leader>fg - Live grep (Telescope)
|
||||
<leader>gs - Git status (Fugitive)
|
||||
<leader>gg - Open LazyGit
|
||||
# 🚀 General Keybinds
|
||||
|
||||
📝 EDITING:
|
||||
gd - Go to definition
|
||||
gr - Find references
|
||||
K - Hover documentation
|
||||
<leader>rn - Rename symbol
|
||||
<Tab> - Next completion item
|
||||
<S-Tab> - Previous completion item
|
||||
<CR> - Confirm completion
|
||||
<C-Space> - Trigger completion
|
||||
( - Auto-complete parentheses
|
||||
- `<leader>e` - Show diagnostic float
|
||||
- `[d` / `]d` - Navigate diagnostics
|
||||
- `<leader>n` - Toggle file explorer (Neo-tree)
|
||||
- `<leader>ff` - Find files (Telescope)
|
||||
- `<leader>fg` - Live grep (Telescope)
|
||||
- `<leader>gs` - Git status (Fugitive)
|
||||
- `<leader>gg` - Open LazyGit
|
||||
|
||||
🌲 NEO-TREE:
|
||||
o / <CR> - Open file
|
||||
t - Open in new tab
|
||||
v - Open in vertical split
|
||||
s - Open in horizontal split
|
||||
r - Rename
|
||||
d - Delete
|
||||
a - Add file
|
||||
A - Add directory
|
||||
R - Refresh
|
||||
. - Toggle hidden files
|
||||
---
|
||||
|
||||
🔭 TELESCOPE:
|
||||
<C-n>/<C-p> - Next/previous item
|
||||
<C-j>/<C-k> - Move selection
|
||||
<C-t> - Open in new tab
|
||||
<C-v> - Open in vertical split
|
||||
<C-x> - Open in horizontal split
|
||||
<C-u> - Clear prompt
|
||||
<C-c> - Close telescope
|
||||
# 📝 Editing
|
||||
|
||||
💻 LSP:
|
||||
<leader>d - Show diagnostics
|
||||
<leader>ca - Code actions
|
||||
<leader>f - Format file
|
||||
<leader>wa - Add workspace folder
|
||||
<leader>wr - Remove workspace folder
|
||||
<leader>wl - List workspace folders
|
||||
- `gd` - Go to definition
|
||||
- `gr` - Find references
|
||||
- `K` - Hover documentation
|
||||
- `<leader>rn` - Rename symbol
|
||||
- `<Tab>` - Next completion item
|
||||
- `<S-Tab>` - Previous completion item
|
||||
- `<CR>` - Confirm completion
|
||||
- `<C-Space>` - Trigger completion
|
||||
- `(` - Auto-complete parentheses
|
||||
|
||||
💾 BUFFER MANAGEMENT:
|
||||
<leader>bd - Delete buffer
|
||||
<leader>bn - Next buffer
|
||||
<leader>bp - Previous buffer
|
||||
<leader>bl - List buffers
|
||||
---
|
||||
|
||||
🐱 GIT:
|
||||
<leader>gc - Git commit
|
||||
<leader>gp - Git push
|
||||
<leader>gl - Git log
|
||||
<leader>gd - Git diff
|
||||
<leader>gb - Git blame
|
||||
# 🌲 Neo-tree
|
||||
|
||||
🔄 TERMINAL:
|
||||
<C-\> - Toggle terminal
|
||||
<Esc><Esc> - Exit terminal mode
|
||||
<leader>tt - New terminal
|
||||
<leader>tf - New floating terminal
|
||||
- `o` / `<CR>` - Open file
|
||||
- `t` - Open in new tab
|
||||
- `v` - Open in vertical split
|
||||
- `s` - Open in horizontal split
|
||||
- `r` - Rename
|
||||
- `d` - Delete
|
||||
- `a` - Add file
|
||||
- `A` - Add directory
|
||||
- `R` - Refresh
|
||||
- `.` - Toggle hidden files
|
||||
|
||||
---
|
||||
|
||||
# 🔭 Telescope
|
||||
|
||||
- `<C-n>` / `<C-p>` - Next/previous item
|
||||
- `<C-j>` / `<C-k>` - Move selection
|
||||
- `<C-t>` - Open in new tab
|
||||
- `<C-v>` - Open in vertical split
|
||||
- `<C-x>` - Open in horizontal split
|
||||
- `<C-u>` - Clear prompt
|
||||
- `<C-c>` - Close telescope
|
||||
|
||||
---
|
||||
|
||||
# 💻 LSP
|
||||
|
||||
- `<leader>d` - Show diagnostics
|
||||
- `<leader>ca` - Code actions
|
||||
- `<leader>f` - Format file
|
||||
- `<leader>wa` - Add workspace folder
|
||||
- `<leader>wr` - Remove workspace folder
|
||||
- `<leader>wl` - List workspace folders
|
||||
|
||||
---
|
||||
|
||||
# 💾 Buffer Management
|
||||
|
||||
- `<leader>bd` - Delete buffer
|
||||
- `<leader>bn` - Next buffer
|
||||
- `<leader>bp` - Previous buffer
|
||||
- `<leader>bl` - List buffers
|
||||
|
||||
---
|
||||
|
||||
# 🐱 Git
|
||||
|
||||
- `<leader>gc` - Git commit
|
||||
- `<leader>gp` - Git push
|
||||
- `<leader>gl` - Git log
|
||||
- `<leader>gd` - Git diff
|
||||
- `<leader>gb` - Git blame
|
||||
|
||||
---
|
||||
|
||||
# 🔄 Terminal
|
||||
|
||||
- `<C-\>` - Toggle terminal
|
||||
- `<Esc><Esc>` - Exit terminal mode
|
||||
- `<leader>tt` - New terminal
|
||||
- `<leader>tf` - New floating terminal
|
||||
|
||||
174
init.lua
174
init.lua
@@ -1,5 +1,5 @@
|
||||
-- ~/.config/nvim/init.lua
|
||||
-- Complete VSCode-like Neovim Config with Enhanced Tab Completion
|
||||
-- Complete VSCode-like Neovim Config with All Requested Keybindings
|
||||
|
||||
-- ======================
|
||||
-- 1. Basic Configuration
|
||||
@@ -7,7 +7,7 @@
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Optimized Editor Settings
|
||||
-- Editor Settings (unchanged from previous)
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.mouse = "a"
|
||||
@@ -58,7 +58,7 @@ vim.opt.rtp:prepend(lazypath)
|
||||
-- 3. Plugin Specifications
|
||||
-- ======================
|
||||
local plugins = {
|
||||
-- Theme
|
||||
-- Theme (unchanged)
|
||||
{
|
||||
"drewtempelmeyer/palenight.vim",
|
||||
priority = 1000,
|
||||
@@ -76,7 +76,7 @@ local plugins = {
|
||||
},
|
||||
|
||||
-- Fuzzy Finder
|
||||
{ "nvim-telescope/telescope.nvim", branch = "0.1.x", dependencies = { "nvim-lua/plenary.nvim" } },
|
||||
{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
|
||||
|
||||
-- LSP Configuration
|
||||
{
|
||||
@@ -104,6 +104,35 @@ local plugins = {
|
||||
},
|
||||
},
|
||||
|
||||
-- Auto Pairs
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require("nvim-autopairs").setup({
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { "string", "source" },
|
||||
javascript = { "string", "template_string" },
|
||||
typescript = { "string", "template_string" },
|
||||
},
|
||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||
fast_wrap = {
|
||||
map = "<M-e>",
|
||||
chars = { "{", "[", "(", '"', "'", "<" },
|
||||
pattern = [=[[%'%"%)%>%]%)%}%,]]=],
|
||||
end_key = "$",
|
||||
highlight = "Search",
|
||||
highlight_grey = "Comment",
|
||||
},
|
||||
})
|
||||
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp = require("cmp")
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
},
|
||||
|
||||
-- Git Integration
|
||||
{ "lewis6991/gitsigns.nvim", opts = {} },
|
||||
{ "tpope/vim-fugitive" },
|
||||
@@ -117,11 +146,10 @@ local plugins = {
|
||||
|
||||
-- Syntax & Editing
|
||||
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
|
||||
{ "windwp/nvim-autopairs", event = "InsertEnter" },
|
||||
{ "numToStr/Comment.nvim", opts = {} },
|
||||
|
||||
-- Productivity
|
||||
{ "akinsho/toggleterm.nvim", version = "*" },
|
||||
{ "akinsho/toggleterm.nvim", version = "*", config = true },
|
||||
{ "folke/which-key.nvim", event = "VimEnter" },
|
||||
{ "stevearc/conform.nvim" },
|
||||
{ "mfussenegger/nvim-lint", event = { "BufReadPre", "BufNewFile" } },
|
||||
@@ -150,7 +178,7 @@ require("lazy").setup(plugins, {
|
||||
},
|
||||
})
|
||||
|
||||
-- Neo-tree Configuration
|
||||
-- Neo-tree Configuration with Keymaps
|
||||
require("neo-tree").setup({
|
||||
close_if_last_window = false,
|
||||
popup_border_style = "rounded",
|
||||
@@ -159,48 +187,57 @@ require("neo-tree").setup({
|
||||
filesystem = {
|
||||
follow_current_file = { enabled = true },
|
||||
hijack_netrw_behavior = "open_current",
|
||||
use_libuv_file_watcher = true,
|
||||
},
|
||||
window = {
|
||||
position = "left",
|
||||
position = "right",
|
||||
width = 30,
|
||||
mappings = { ["<space>"] = "none" },
|
||||
mappings = {
|
||||
["<space>"] = "none", -- disable space as it's our leader key
|
||||
["o"] = "open",
|
||||
["<CR>"] = "open",
|
||||
["t"] = "open_tabnew",
|
||||
["v"] = "open_vsplit",
|
||||
["s"] = "open_split",
|
||||
["r"] = "rename",
|
||||
["d"] = "delete",
|
||||
["a"] = "add",
|
||||
["A"] = "add_directory",
|
||||
["R"] = "refresh",
|
||||
["."] = "toggle_hidden",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Telescope Configuration
|
||||
-- Telescope Configuration with Keymaps
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-u>"] = false,
|
||||
["<C-d>"] = false,
|
||||
["<C-n>"] = "move_selection_next",
|
||||
["<C-p>"] = "move_selection_previous",
|
||||
["<C-j>"] = "move_selection_next",
|
||||
["<C-k>"] = "move_selection_previous",
|
||||
["<C-t>"] = "select_tab",
|
||||
["<C-v>"] = "select_vertical",
|
||||
["<C-x>"] = "select_horizontal",
|
||||
["<C-u>"] = "clear_prompt",
|
||||
["<C-c>"] = "close",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- LSP Setup with Enhanced Completion
|
||||
-- LSP Setup
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = { "documentation", "detail", "additionalTextEdits" },
|
||||
}
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"ruff",
|
||||
"ts_ls",
|
||||
"html",
|
||||
"cssls",
|
||||
"tailwindcss",
|
||||
"bashls",
|
||||
"jsonls",
|
||||
"yamlls",
|
||||
"dockerls",
|
||||
"lua_ls", "pyright", "ruff", "tsserver", "html", "cssls",
|
||||
"tailwindcss", "bashls", "jsonls", "yamlls", "dockerls"
|
||||
},
|
||||
})
|
||||
|
||||
@@ -210,19 +247,20 @@ lspconfig.lua_ls.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = { callSnippet = "Replace" },
|
||||
diagnostics = { globals = { "vim" } },
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Configure other LSP servers similarly
|
||||
for _, server in ipairs({ "pyright", "ts_ls", "html", "cssls" }) do
|
||||
for _, server in ipairs({ "pyright", "tsserver", "html", "cssls", "bashls", "jsonls" }) do
|
||||
lspconfig[server].setup({ capabilities = capabilities })
|
||||
end
|
||||
|
||||
-- Advanced Completion Setup
|
||||
-- Completion Setup
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
local has_words_before = function()
|
||||
@@ -260,7 +298,10 @@ cmp.setup({
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
}),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
@@ -269,41 +310,54 @@ cmp.setup({
|
||||
{ name = "path" },
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(entry, item)
|
||||
item.menu = ({
|
||||
nvim_lsp = "[LSP]",
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
path = "[Path]",
|
||||
})[entry.source.name]
|
||||
return item
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
-- ======================
|
||||
-- 5. Key Mappings
|
||||
-- ======================
|
||||
-- Navigation
|
||||
|
||||
-- 🚀 General Keybinds
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
|
||||
|
||||
-- File Management
|
||||
vim.keymap.set("n", "<leader>n", ":Neotree toggle<CR>")
|
||||
vim.keymap.set("n", "<leader>ff", ":Telescope find_files<CR>")
|
||||
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<CR>")
|
||||
vim.keymap.set("n", "<leader>gs", ":Git<CR>")
|
||||
vim.keymap.set("n", "<leader>gg", ":LazyGit<CR>")
|
||||
|
||||
-- LSP
|
||||
-- 📝 Editing
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename)
|
||||
|
||||
-- Git
|
||||
vim.keymap.set("n", "<leader>gs", ":Git<CR>")
|
||||
vim.keymap.set("n", "<leader>gg", ":LazyGit<CR>")
|
||||
-- 💻 LSP
|
||||
vim.keymap.set("n", "<leader>d", vim.diagnostic.setloclist)
|
||||
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action)
|
||||
vim.keymap.set("n", "<leader>f", function() vim.lsp.buf.format({ async = true }) end)
|
||||
vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder)
|
||||
vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder)
|
||||
vim.keymap.set("n", "<leader>wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end)
|
||||
|
||||
-- 💾 Buffer Management
|
||||
vim.keymap.set("n", "<leader>bd", ":bdelete<CR>")
|
||||
vim.keymap.set("n", "<leader>bn", ":bnext<CR>")
|
||||
vim.keymap.set("n", "<leader>bp", ":bprevious<CR>")
|
||||
vim.keymap.set("n", "<leader>bl", ":Telescope buffers<CR>")
|
||||
|
||||
-- 🐱 Git
|
||||
vim.keymap.set("n", "<leader>gc", ":Git commit<CR>")
|
||||
vim.keymap.set("n", "<leader>gp", ":Git push<CR>")
|
||||
vim.keymap.set("n", "<leader>gl", ":Telescope git_commits<CR>")
|
||||
vim.keymap.set("n", "<leader>gd", ":Gdiff<CR>")
|
||||
vim.keymap.set("n", "<leader>gb", ":Git blame<CR>")
|
||||
|
||||
-- 🔄 Terminal
|
||||
vim.keymap.set("t", "<C-\\>", "<C-\\><C-n>") -- Escape terminal mode
|
||||
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>") -- Alternative escape
|
||||
vim.keymap.set("n", "<leader>tt", ":ToggleTerm<CR>")
|
||||
vim.keymap.set("n", "<leader>tf", ":ToggleTerm direction=float<CR>")
|
||||
|
||||
-- ======================
|
||||
-- 6. Autocommands
|
||||
@@ -322,8 +376,18 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
end,
|
||||
})
|
||||
|
||||
print("🚀 Neovim configuration fully loaded with:")
|
||||
print(" - VSCode-like tab completion")
|
||||
print(" - Enhanced LSP support")
|
||||
print(" - Git integration")
|
||||
print(" - Beautiful UI components")
|
||||
-- Enable treesitter
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = { "lua", "python", "javascript", "typescript", "html", "css", "bash", "json", "yaml" },
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
|
||||
-- ======================
|
||||
-- 7. Final Setup
|
||||
-- ======================
|
||||
print("🚀 Neovim configuration fully loaded with all keybindings:")
|
||||
print(" - General navigation and file management")
|
||||
print(" - Advanced editing and LSP features")
|
||||
print(" - Complete Git integration")
|
||||
print(" - Terminal and buffer management")
|
||||
|
||||
Reference in New Issue
Block a user