diff --git a/init.lua b/init.lua index 020b08b..81513fe 100644 --- a/init.lua +++ b/init.lua @@ -19,13 +19,16 @@ vim.o.winborder = "rounded" -- Sane keymaps vim.keymap.set("i", "jj", "") vim.keymap.set("n", "q:", ":", { noremap = true, silent = true }) -vim.keymap.set("n", "bq", "bd", { noremap = true, silent = true }) +vim.keymap.set("n", "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", "", 'echo "Use l to move!!"') vim.keymap.set("n", "", 'echo "Use k to move!!"') vim.keymap.set("n", "", 'echo "Use j to move!!"') --- Center cursor after scrolling with Ctrl-d / Ctrl-u -vim.keymap.set("n", "", "zz", { desc = "Half page up" }) -vim.keymap.set("n", "", "zz", { desc = "Half page down" }) - -- C-BS for deleting whole word in insert mode vim.keymap.set("i", "", "", { noremap = true }) -- Keybinds for saving and stuff vim.keymap.set("n", "qq", "qa!", { noremap = true }) -vim.keymap.set("n", "qs", function() +vim.keymap.set("n", "qs", function() -- quit and save session vim.cmd("AutoSession save") vim.cmd("wqa") end, { noremap = true }) +vim.keymap.set("n", "qd", function() -- quit and delete session + vim.cmd("AutoSession delete") + vim.cmd("wqa") +end, { noremap = true }) diff --git a/lua/plugins/completion/blink.lua b/lua/plugins/completion/blink.lua new file mode 100644 index 0000000..de8f6a4 --- /dev/null +++ b/lua/plugins/completion/blink.lua @@ -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 = { + [""] = { "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 + }, + }, + }, +} diff --git a/lua/plugins/completion/cmp.lua b/lua/plugins/completion/cmp.lua deleted file mode 100644 index da90a32..0000000 --- a/lua/plugins/completion/cmp.lua +++ /dev/null @@ -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({ - [""] = 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" }), - [""] = 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" }), - [""] = 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, -} diff --git a/lua/plugins/completion/lazydev.lua b/lua/plugins/completion/lazydev.lua new file mode 100644 index 0000000..e06cb4c --- /dev/null +++ b/lua/plugins/completion/lazydev.lua @@ -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, + }, + }, + }, + }, + }, +} diff --git a/lua/plugins/completion/lspconfig.lua b/lua/plugins/completion/lspconfig.lua index f412319..bc12026 100644 --- a/lua/plugins/completion/lspconfig.lua +++ b/lua/plugins/completion/lspconfig.lua @@ -1,55 +1,37 @@ 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 = { - filetypes = { "html", "css", "javascriptreact", "typescriptreact" }, - init_options = { - html = { - options = { - ["bem.enabled"] = true, - }, + 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", }, }, - -- Note: We no longer need to define 'capabilities' here, - -- as it gets the merged default from the config function. }, - }, - }, + }) + vim.lsp.config("emmet_ls", { + -- capabilities = require("cmp_nvim_lsp").default_capabilities(), + filetypes = { "html", "css", "javascriptreact", "typescriptreact" }, + init_options = { + html = { + options = { + ["bem.enabled"] = true, + }, + }, + }, + }) + vim.lsp.enable({ + "lua_ls", + "ts_ls", + "cssls", + "rust_analyzer", + "emmet_ls", + }) + end, } diff --git a/lua/plugins/functional/flash.lua b/lua/plugins/functional/flash.lua index 188bc41..ebf713b 100644 --- a/lua/plugins/functional/flash.lua +++ b/lua/plugins/functional/flash.lua @@ -5,7 +5,7 @@ return { opts = {}, keys = { { - "s", + "ss", mode = { "n", "x", "o" }, function() require("flash").jump() @@ -13,7 +13,7 @@ return { desc = "Flash", }, { - "S", + "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() diff --git a/lua/plugins/functional/telescope-file-browser.lua b/lua/plugins/functional/telescope-file-browser.lua new file mode 100644 index 0000000..4e996b7 --- /dev/null +++ b/lua/plugins/functional/telescope-file-browser.lua @@ -0,0 +1,4 @@ +return { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" }, +} diff --git a/lua/plugins/functional/telescope.lua b/lua/plugins/functional/telescope.lua index a20758e..8e499fb 100644 --- a/lua/plugins/functional/telescope.lua +++ b/lua/plugins/functional/telescope.lua @@ -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", "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", "fn", function() + require("telescope").extensions.file_browser.file_browser() + end) + vim.keymap.set("n", "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", "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, }