initial commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
require("config.options")
|
||||||
|
require("config.keymaps")
|
||||||
|
require("config.autocmds")
|
||||||
|
require("config.lazy")
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
|
||||||
|
"LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" },
|
||||||
|
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
|
||||||
|
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||||
|
"conform.nvim": { "branch": "master", "commit": "c2526f1cde528a66e086ab1668e996d162c75f4f" },
|
||||||
|
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
|
||||||
|
"gitsigns.nvim": { "branch": "main", "commit": "42d6aed4e94e0f0bbced16bbdcc42f57673bd75e" },
|
||||||
|
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
||||||
|
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||||
|
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
|
||||||
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "80c0130c5f16b551865a69e832f1feadeedb5fbe" },
|
||||||
|
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
|
||||||
|
"nvim": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" },
|
||||||
|
"nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" },
|
||||||
|
"nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" },
|
||||||
|
"nvim-lspconfig": { "branch": "master", "commit": "92ee7d42320edfbb81f3cad851314ab197fa324a" },
|
||||||
|
"nvim-treesitter": { "branch": "main", "commit": "e75c007f2747050c2c620dc862c77b8f242551a8" },
|
||||||
|
"nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" },
|
||||||
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
|
"telescope.nvim": { "branch": "master", "commit": "0d8b6eaa0b5ae6bb3d9785f7a3ba4a4c6c1b1af2" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
local augroup = vim.api.nvim_create_augroup("UserConfig", { clear = true })
|
||||||
|
|
||||||
|
-- Go uses tabs by convention
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
group = augroup,
|
||||||
|
pattern = "go",
|
||||||
|
callback = function()
|
||||||
|
vim.opt_local.expandtab = false
|
||||||
|
vim.opt_local.tabstop = 4
|
||||||
|
vim.opt_local.shiftwidth = 4
|
||||||
|
end,
|
||||||
|
})
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
local map = vim.keymap.set
|
||||||
|
|
||||||
|
-- Save/Quit
|
||||||
|
map("n", "<leader>w", "<cmd>w<cr>", { desc = "Save" })
|
||||||
|
map("n", "<leader>q", "<cmd>q<cr>", { desc = "Quit" })
|
||||||
|
|
||||||
|
-- Better movement with wrapped lines (just in case you turn wrap on)
|
||||||
|
map("n", "j", "gj", { noremap = true })
|
||||||
|
map("n", "k", "gk", { noremap = true })
|
||||||
|
|
||||||
|
-- Clear search highlight
|
||||||
|
map("n", "<leader>h", "<cmd>nohlsearch<cr>", { desc = "No highlight" })
|
||||||
|
|
||||||
|
-- Diagnostics
|
||||||
|
map("n", "[d", vim.diagnostic.goto_prev, { desc = "Prev diagnostic" })
|
||||||
|
map("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" })
|
||||||
|
map("n", "<leader>e", vim.diagnostic.open_float, { desc = "Diagnostic float" })
|
||||||
|
|
||||||
|
-- Window navigation
|
||||||
|
map("n", "<C-h>", "<C-w>h", { desc = "Left window" })
|
||||||
|
map("n", "<C-j>", "<C-w>j", { desc = "Down window" })
|
||||||
|
map("n", "<C-k>", "<C-w>k", { desc = "Up window" })
|
||||||
|
map("n", "<C-l>", "<C-w>l", { desc = "Right window" })
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
-- 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
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||||
|
-- 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 your plugins
|
||||||
|
{ import = "plugins" },
|
||||||
|
},
|
||||||
|
-- Configure any other settings here. See the documentation for more details.
|
||||||
|
-- colorscheme that will be used when installing plugins.
|
||||||
|
install = { colorscheme = { "habamax" } },
|
||||||
|
-- automatically check for plugin updates
|
||||||
|
checker = { enabled = true },
|
||||||
|
})
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
|
local opt = vim.opt
|
||||||
|
|
||||||
|
opt.number = true
|
||||||
|
opt.relativenumber = true
|
||||||
|
opt.signcolumn = "yes"
|
||||||
|
opt.cursorline = true
|
||||||
|
opt.termguicolors = true
|
||||||
|
|
||||||
|
opt.tabstop = 2
|
||||||
|
opt.shiftwidth = 2
|
||||||
|
opt.expandtab = true
|
||||||
|
opt.smartindent = true
|
||||||
|
|
||||||
|
opt.wrap = false
|
||||||
|
opt.scrolloff = 8
|
||||||
|
|
||||||
|
opt.ignorecase = true
|
||||||
|
opt.smartcase = true
|
||||||
|
|
||||||
|
opt.splitbelow = true
|
||||||
|
opt.splitright = true
|
||||||
|
|
||||||
|
opt.clipboard = "unnamedplus"
|
||||||
|
opt.mouse = "a"
|
||||||
|
|
||||||
|
opt.updatetime = 250
|
||||||
|
opt.timeoutlen = 400
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
return {
|
||||||
|
-- Better highlighting and parsing
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
build = ":TSUpdate",
|
||||||
|
config = function()
|
||||||
|
require("nvim-treesitter.config").setup({
|
||||||
|
highlight = { enabled = true },
|
||||||
|
additional_vim_regex_highlighting = false,
|
||||||
|
indent = { enabled = true },
|
||||||
|
ensure_installed = {
|
||||||
|
"go",
|
||||||
|
"gomod",
|
||||||
|
"gosum",
|
||||||
|
"gowork",
|
||||||
|
"typescript",
|
||||||
|
"tsx",
|
||||||
|
"javascript",
|
||||||
|
"json",
|
||||||
|
"lua",
|
||||||
|
"vimdoc",
|
||||||
|
"markdown",
|
||||||
|
"yaml",
|
||||||
|
"bash",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
return {
|
||||||
|
-- Fuzzy finder (files, text, symbols)
|
||||||
|
{
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
|
config = function()
|
||||||
|
local telescope = require("telescope")
|
||||||
|
telescope.setup({})
|
||||||
|
local map = vim.keymap.set
|
||||||
|
map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Find files" })
|
||||||
|
map("n", "<leader>fg", "<cmd>Telescope live_grep<cr>", { desc = "Live grep" })
|
||||||
|
map("n", "<leader>fb", "<cmd>Telescope buffers<cr>", { desc = "Buffers" })
|
||||||
|
map("n", "<leader>fh", "<cmd>Telescope help_tags<cr>", { desc = "Help" })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Git decorations in the gutter
|
||||||
|
{
|
||||||
|
"lewis6991/gitsigns.nvim",
|
||||||
|
config = function()
|
||||||
|
require("gitsigns").setup()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- “Press leader and see options” (amazing for beginners)
|
||||||
|
{
|
||||||
|
"folke/which-key.nvim",
|
||||||
|
config = function()
|
||||||
|
require("which-key").setup()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Auto-close (), {}, "", etc.
|
||||||
|
{
|
||||||
|
"windwp/nvim-autopairs",
|
||||||
|
config = function()
|
||||||
|
require("nvim-autopairs").setup()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Comment toggling
|
||||||
|
{
|
||||||
|
"numToStr/Comment.nvim",
|
||||||
|
config = function()
|
||||||
|
require("Comment").setup()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Indent guides
|
||||||
|
{
|
||||||
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
|
main = "ibl",
|
||||||
|
config = function()
|
||||||
|
require("ibl").setup()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
-- ~/.config/nvim/lua/plugins/lsp.lua
|
||||||
|
return {
|
||||||
|
-- Installs LSP servers (and other tools) easily
|
||||||
|
{
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
config = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mason-org/mason-lspconfig.nvim",
|
||||||
|
dependencies = { "williamboman/mason.nvim" },
|
||||||
|
opts = {
|
||||||
|
-- installs these via Mason (so you don't have to)
|
||||||
|
ensure_installed = { "gopls", "ts_ls", "lua_ls" },
|
||||||
|
|
||||||
|
-- optional: automatically call vim.lsp.enable() for installed servers
|
||||||
|
automatic_enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Provides server defaults (configs, root markers, etc.)
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
dependencies = { "mason-org/mason-lspconfig.nvim" },
|
||||||
|
config = function()
|
||||||
|
-- LSP keymaps when a server attaches
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(args)
|
||||||
|
local map = function(mode, lhs, rhs, desc)
|
||||||
|
vim.keymap.set(mode, lhs, rhs, { buffer = args.buf, desc = desc })
|
||||||
|
end
|
||||||
|
|
||||||
|
map("n", "gd", vim.lsp.buf.definition, "Go to definition")
|
||||||
|
map("n", "gr", vim.lsp.buf.references, "References")
|
||||||
|
map("n", "K", vim.lsp.buf.hover, "Hover")
|
||||||
|
map("n", "<leader>rn", vim.lsp.buf.rename, "Rename")
|
||||||
|
map("n", "<leader>ca", vim.lsp.buf.code_action, "Code action")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- If you use nvim-cmp, advertise completion capabilities to LSP servers
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
local ok_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
if ok_cmp then
|
||||||
|
capabilities = cmp_lsp.default_capabilities(capabilities)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Register/override configs using the NEW API (Neovim 0.11+)
|
||||||
|
-- nvim-lspconfig supplies the baseline config; this adds your custom bits.
|
||||||
|
vim.lsp.config("gopls", {
|
||||||
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
gopls = {
|
||||||
|
gofumpt = true,
|
||||||
|
analyses = { unusedparams = true },
|
||||||
|
staticcheck = true,
|
||||||
|
semanticTokens = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.config("ts_ls", {
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.config("lua_ls", {
|
||||||
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = { globals = { "vim" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- If you did NOT set mason-lspconfig automatic_enable=true,
|
||||||
|
-- enable explicitly:
|
||||||
|
-- vim.lsp.enable({ "gopls", "ts_ls", "lua_ls" })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Completion (nvim-cmp)
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
dependencies = {
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args) luasnip.lsp_expand(args.body) end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
["<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" }),
|
||||||
|
}),
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Formatting (format-on-save)
|
||||||
|
{
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
config = function()
|
||||||
|
require("conform").setup({
|
||||||
|
format_on_save = function()
|
||||||
|
return { timeout_ms = 2000, lsp_fallback = true }
|
||||||
|
end,
|
||||||
|
formatters_by_ft = {
|
||||||
|
go = { "goimports", "gofmt" },
|
||||||
|
typescript = { "prettierd", "prettier" },
|
||||||
|
typescriptreact = { "prettierd", "prettier" },
|
||||||
|
javascript = { "prettierd", "prettier" },
|
||||||
|
javascriptreact = { "prettierd", "prettier" },
|
||||||
|
json = { "prettierd", "prettier" },
|
||||||
|
lua = { "stylua" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>f", function()
|
||||||
|
require("conform").format({ async = true, lsp_fallback = true })
|
||||||
|
end, { desc = "Format" })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
return {
|
||||||
|
{ "nvim-tree/nvim-web-devicons", lazy = true },
|
||||||
|
|
||||||
|
-- Theme: pick ONE. TokyoNight is a safe default.
|
||||||
|
{
|
||||||
|
"catppuccin/nvim",
|
||||||
|
priority = 1000,
|
||||||
|
config = function()
|
||||||
|
require("catppuccin").setup({
|
||||||
|
integrations = {
|
||||||
|
treesitter = true,
|
||||||
|
native_lsp = {
|
||||||
|
enabled = true,
|
||||||
|
semantic_tokens = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
vim.cmd.colorscheme("catppuccin-mocha")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Statusline
|
||||||
|
{
|
||||||
|
"nvim-lualine/lualine.nvim",
|
||||||
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||||
|
config = function()
|
||||||
|
require("lualine").setup({
|
||||||
|
options = { theme = "auto", globalstatus = true },
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user