major improvements, better stuff overall
This commit is contained in:
23
init.lua
23
init.lua
@@ -19,13 +19,16 @@ vim.o.winborder = "rounded"
|
||||
-- Sane keymaps
|
||||
vim.keymap.set("i", "jj", "<Esc>")
|
||||
vim.keymap.set("n", "q:", ":", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>bq", "<cmd>bd<CR>", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>bd", function() -- delete buffer
|
||||
vim.cmd("bd")
|
||||
vim.cmd("echo 'Buffer deleted'")
|
||||
end, { noremap = true })
|
||||
|
||||
-- Sane tab management
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.expandtab = false
|
||||
|
||||
-- Undo management
|
||||
vim.opt.swapfile = false
|
||||
@@ -49,16 +52,16 @@ vim.keymap.set("n", "<right>", '<cmd>echo "Use l to move!!"<CR>')
|
||||
vim.keymap.set("n", "<up>", '<cmd>echo "Use k to move!!"<CR>')
|
||||
vim.keymap.set("n", "<down>", '<cmd>echo "Use j to move!!"<CR>')
|
||||
|
||||
-- Center cursor after scrolling with Ctrl-d / Ctrl-u
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Half page up" })
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Half page down" })
|
||||
|
||||
-- C-BS for deleting whole word in insert mode
|
||||
vim.keymap.set("i", "<C-BS>", "<C-W>", { noremap = true })
|
||||
|
||||
-- Keybinds for saving and stuff
|
||||
vim.keymap.set("n", "<leader>qq", "<cmd>qa!<CR>", { noremap = true })
|
||||
vim.keymap.set("n", "<leader>qs", function()
|
||||
vim.keymap.set("n", "<leader>qs", function() -- quit and save session
|
||||
vim.cmd("AutoSession save")
|
||||
vim.cmd("wqa")
|
||||
end, { noremap = true })
|
||||
vim.keymap.set("n", "<leader>qd", function() -- quit and delete session
|
||||
vim.cmd("AutoSession delete")
|
||||
vim.cmd("wqa")
|
||||
end, { noremap = true })
|
||||
|
||||
47
lua/plugins/completion/blink.lua
Normal file
47
lua/plugins/completion/blink.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
return {
|
||||
"saghen/blink.cmp",
|
||||
dependencies = {
|
||||
"L3MON4D3/LuaSnip",
|
||||
},
|
||||
opts = {
|
||||
providers = {
|
||||
lazydev = {
|
||||
name = "LazyDev",
|
||||
module = "lazydev.integrations.blink",
|
||||
priority = 100,
|
||||
},
|
||||
},
|
||||
|
||||
-- Snippet configuration
|
||||
snippets = {
|
||||
preset = "luasnip", -- Tells blink.cmp to use LuaSnip
|
||||
},
|
||||
|
||||
fuzzy = { implementation = "lua" },
|
||||
|
||||
signature = { enabled = true },
|
||||
|
||||
completion = {
|
||||
list = {
|
||||
selection = {
|
||||
preselect = false,
|
||||
auto_insert = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Keymaps
|
||||
keymap = {
|
||||
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
|
||||
},
|
||||
sources = {
|
||||
default = {
|
||||
"lsp", -- (Equivalent to cmp-nvim-lsp)
|
||||
"snippets", -- (Handled by the snippets config, replaces cmp_luasnip source)
|
||||
"buffer", -- (Equivalent to cmp-buffer)
|
||||
"path", -- (Equivalent to cmp-path)
|
||||
-- "cmdline", -- Generally configured separately, but often included by default
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip", -- Completion for snippets
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Confirm selection with Enter
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" }, -- This should provide LSP completions like for ESLint
|
||||
-- { name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
25
lua/plugins/completion/lazydev.lua
Normal file
25
lua/plugins/completion/lazydev.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
return {
|
||||
{
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua", -- only load on lua files
|
||||
opts = {
|
||||
library = {
|
||||
-- See the configuration section for more details
|
||||
-- Load luvit types when the `vim.uv` word is found
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
sources = {
|
||||
-- add lazydev to your completion providers
|
||||
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
|
||||
providers = {
|
||||
lazydev = {
|
||||
name = "LazyDev",
|
||||
module = "lazydev.integrations.blink",
|
||||
-- make lazydev completions top priority (see `:h blink.cmp`)
|
||||
score_offset = 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,44 +1,22 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
-- This custom config function will run *instead* of the default.
|
||||
-- It receives the 'opts' table (second argument) and loops through it.
|
||||
config = function(_, opts)
|
||||
-- 1. Get the default capabilities from cmp_nvim_lsp
|
||||
-- (Your emmet_ls config was already using this, so we'll make it
|
||||
-- the default for all servers. This includes snippetSupport.)
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- 2. Loop over the servers defined in 'opts.servers'
|
||||
for server_name, server_config in pairs(opts.servers or {}) do
|
||||
-- 3. Merge default capabilities with server-specific config
|
||||
-- 'vim.tbl_deep_extend' ensures server-specific settings
|
||||
-- (like for emmet_ls) are preserved.
|
||||
local config = vim.tbl_deep_extend("force", {
|
||||
capabilities = capabilities,
|
||||
}, server_config or {})
|
||||
|
||||
-- 4. Setup the server
|
||||
lspconfig[server_name].setup(config)
|
||||
end
|
||||
end,
|
||||
|
||||
-- 'opts' table now holds all server-specific configurations
|
||||
opts = {
|
||||
servers = {
|
||||
-- Servers with no special config are just empty tables
|
||||
nil_ls = {},
|
||||
nixd = {},
|
||||
lua_ls = {},
|
||||
pyright = {},
|
||||
cssls = {}, -- No longer needs 'capabilities = capabilities'
|
||||
ts_ls = {}, -- No longer needs 'capabilities = capabilities'
|
||||
rust_analyzer = {},
|
||||
|
||||
-- emmet_ls settings are preserved here
|
||||
emmet_ls = {
|
||||
config = function()
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
-- Tell the server to let Neovim handle snippet expansion
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
-- Use LuaJIT (which Neovim uses)
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.config("emmet_ls", {
|
||||
-- capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
|
||||
init_options = {
|
||||
html = {
|
||||
@@ -47,9 +25,13 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
-- Note: We no longer need to define 'capabilities' here,
|
||||
-- as it gets the merged default from the config function.
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.enable({
|
||||
"lua_ls",
|
||||
"ts_ls",
|
||||
"cssls",
|
||||
"rust_analyzer",
|
||||
"emmet_ls",
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ return {
|
||||
opts = {},
|
||||
keys = {
|
||||
{
|
||||
"<leader>s",
|
||||
"ss",
|
||||
mode = { "n", "x", "o" },
|
||||
function()
|
||||
require("flash").jump()
|
||||
@@ -13,7 +13,7 @@ return {
|
||||
desc = "Flash",
|
||||
},
|
||||
{
|
||||
"<leader>S",
|
||||
"S",
|
||||
mode = { "n", "x", "o" },
|
||||
function()
|
||||
require("flash").treesitter()
|
||||
|
||||
4
lua/plugins/functional/telescope-file-browser.lua
Normal file
4
lua/plugins/functional/telescope-file-browser.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
return {
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
|
||||
}
|
||||
@@ -3,19 +3,36 @@ return {
|
||||
tag = "0.1.8",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
require("telescope").setup()
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
file_ignore_patterns = { ".git" },
|
||||
},
|
||||
extensions = {
|
||||
file_browser = {
|
||||
theme = "ivy",
|
||||
-- disables netrw and use telescope-file-browser in its place
|
||||
hijack_netrw = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
local builtin = require("telescope.builtin")
|
||||
|
||||
vim.keymap.set("n", "<leader>ff", function()
|
||||
builtin.find_files({ cwd = vim.fn.expand("%:p:h"), hidden = true })
|
||||
builtin.find_files({ hidden = true })
|
||||
end, { desc = "Telescope find files (current file dir)" })
|
||||
|
||||
vim.keymap.set("n", "<space>fn", function()
|
||||
require("telescope").extensions.file_browser.file_browser()
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<leader>fg", function()
|
||||
builtin.live_grep({ cwd = vim.fn.expand("%:p:h") })
|
||||
builtin.live_grep()
|
||||
end, { desc = "Telescope live grep (current file dir)" })
|
||||
|
||||
vim.keymap.set("n", "<leader>fb", function()
|
||||
builtin.buffers({ cwd = vim.fn.expand("%:p:h") }) -- buffers don’t need cwd, but harmless
|
||||
end, { desc = "Telescope buffers" })
|
||||
|
||||
require("telescope").load_extension("file_browser")
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user