refactor: redid neovim config

This commit is contained in:
2025-01-23 07:46:05 +00:00
parent 85a46854fe
commit fbffcffe21
16 changed files with 132 additions and 251 deletions

26
.config/nvim/lua/rocketcamel/config/lazy.lua Executable file → Normal file
View File

@@ -1,17 +1,17 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
@@ -19,11 +19,13 @@ vim.opt.rtp:prepend(lazypath)
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
{ import = "rocketcamel.plugins" }
-- import your plugins
{ import = "rocketcamel.plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.

0
.config/nvim/lua/rocketcamel/init.lua Executable file → Normal file
View File

View File

@@ -0,0 +1,20 @@
return {
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
lua = { "stylua" },
rust = { "rustfmt", lsp_format = "fallback" },
javascript = { "prettier" },
typescript = { "prettier" },
json = { "prettier" },
tsx = { "prettier" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_format = "fallback",
},
},
},
}

View File

@@ -1,193 +0,0 @@
return {
{
"nvim-telescope/telescope.nvim",
config = function()
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
vim.keymap.set("n", "<C-p>", builtin.git_files, {})
vim.keymap.set("n", "<leader>ps", function()
builtin.grep_string({ search = vim.fn.input("Grep > ") })
end)
end,
},
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"c",
"lua",
"vim",
"vimdoc",
"query",
"markdown",
"markdown_inline",
"javascript",
"typescript",
"tsx",
"rust",
"zig",
},
sync_install = true,
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
},
},
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/nvim-cmp",
"j-hui/fidget.nvim",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lsp-signature-help",
},
config = function()
require("fidget").setup({})
require("mason").setup()
local capabilities = require("cmp_nvim_lsp").default_capabilities()
require("mason-lspconfig").setup({
ensure_installed = {
"ts_ls",
"lua_ls",
"rust_analyzer",
},
handlers = {
function(server)
require("lspconfig")[server].setup({ capabilities = capabilities })
end,
},
})
local cmp = require("cmp")
cmp.setup({
preselect = "item",
completion = {
completeopt = "menu,menuone,noinsert"
},
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = cmp.mapping.preset.insert({
-- Simple tab complete
["<Tab>"] = cmp.mapping(function(fallback)
local col = vim.fn.col(".") - 1
if cmp.visible() then
cmp.select_next_item({ behavior = "select" })
elseif col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then
fallback()
else
cmp.complete()
end
end, { "i", "s" }),
-- Go to previous item
["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = "select" }),
["<CR>"] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "nvim_lsp_signature_help" },
}, {
{ name = "buffer" },
}),
})
end,
},
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
lua = { "stylua" },
rust = { "rustfmt", lsp_format = "fallback" },
javascript = { "prettier" },
typescript = { "prettier" },
json = { "prettier" },
tsx = { "prettier" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_format = "fallback",
},
},
},
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
harpoon:setup()
vim.keymap.set("n", "<leader>a", function()
harpoon:list():add()
end)
vim.keymap.set("n", "<C-e>", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end)
vim.keymap.set("n", "<C-h>", function()
harpoon:list():select(1)
end)
vim.keymap.set("n", "<C-t>", function()
harpoon:list():select(2)
end)
vim.keymap.set("n", "<C-n>", function()
harpoon:list():select(3)
end)
vim.keymap.set("n", "<C-s>", function()
harpoon:list():select(4)
end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<C-S-P>", function()
harpoon:list():prev()
end)
vim.keymap.set("n", "<C-S-N>", function()
harpoon:list():next()
end)
end,
},
{
"m4xshen/autoclose.nvim",
opts = {
keys = {
["("] = { escape = false, close = true, pair = "()" },
["["] = { escape = false, close = true, pair = "[]" },
["{"] = { escape = false, close = true, pair = "{}" },
[">"] = { escape = true, close = false, pair = "<>" },
[")"] = { escape = true, close = false, pair = "()" },
["]"] = { escape = true, close = false, pair = "[]" },
["}"] = { escape = true, close = false, pair = "{}" },
['"'] = { escape = true, close = true, pair = '""' },
["'"] = { escape = true, close = true, pair = "''" },
["`"] = { escape = true, close = true, pair = "``" },
},
options = {
disabled_filetypes = { "text", "TelescopePrompt" },
disable_when_touch = false,
touch_regex = "[%w(%[{]",
pair_spaces = false,
auto_indent = true,
disable_command_mode = false,
},
},
},
}

View File

@@ -0,0 +1,26 @@
return {
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"j-hui/fidget.nvim",
},
config = function()
require("mason").setup()
require("fidget").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"ts_ls",
"lua_ls",
"rust_analyzer",
},
handlers = {
function(server)
require("lspconfig")[server].setup({})
end,
},
})
end,
},
}

View File

@@ -0,0 +1,11 @@
return {
{
"echasnovski/mini.nvim",
version = false,
config = function()
require("mini.completion").setup()
require("mini.fuzzy").setup()
require("mini.pairs").setup()
end,
},
}

View File

@@ -1,22 +0,0 @@
return {
"windwp/nvim-ts-autotag",
lazy = false,
config = function()
require("nvim-ts-autotag").setup({
opts = {
enable_close = true,
enable_rename = true,
enable_close_on_slash = false
}
})
end
-- opts = {
-- per_filetype = {
-- "html",
-- "javascript",
-- "javascriptreact",
-- "typescript",
-- "typescriptreact",
-- }
--}
}

16
.config/nvim/lua/rocketcamel/plugins/rose-pine.lua Executable file → Normal file
View File

@@ -1,6 +1,14 @@
return {
"rose-pine/neovim",
config = function()
vim.cmd("colorscheme rose-pine")
end,
{
"rose-pine/neovim",
name = "rose-pine",
config = function()
require("rose-pine").setup({
styles = {
transparency = true,
},
})
vim.cmd("colorscheme rose-pine")
end,
},
}

View File

@@ -0,0 +1,13 @@
return {
{
"nvim-telescope/telescope.nvim",
config = function()
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
vim.keymap.set("n", "<C-p>", builtin.git_files, {})
vim.keymap.set("n", "<leader>ps", function()
builtin.grep_string({ search = vim.fn.input("Grep > ") })
end)
end,
},
}

View File

@@ -0,0 +1,30 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"c",
"lua",
"vim",
"vimdoc",
"query",
"markdown",
"markdown_inline",
"javascript",
"typescript",
"tsx",
"rust",
"zig",
},
sync_install = true,
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
},
},
}

0
.config/nvim/lua/rocketcamel/remap.lua Executable file → Normal file
View File

0
.config/nvim/lua/rocketcamel/set.lua Executable file → Normal file
View File