init
commit
afb9b59235
|
@ -0,0 +1,5 @@
|
||||||
|
require('configs.options')
|
||||||
|
require('configs.mappings')
|
||||||
|
require('configs.lazy')
|
||||||
|
|
||||||
|
require("functions.lsp")
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"blink.cmp": { "branch": "main", "commit": "c2bac7fba61e66dfc513cf63daa98546c86a617c" },
|
||||||
|
"conform.nvim": { "branch": "master", "commit": "a4bb5d6c4ae6f32ab13114e62e70669fa67745b9" },
|
||||||
|
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
|
||||||
|
"gitsigns.nvim": { "branch": "main", "commit": "ee0606259ee5d5dd40398be26755048e8965086e" },
|
||||||
|
"gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" },
|
||||||
|
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||||
|
"mason.nvim": { "branch": "main", "commit": "1aceba8bc158b5aaf90649077cad06744bc23ac4" },
|
||||||
|
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
|
||||||
|
"nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" },
|
||||||
|
"nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" },
|
||||||
|
"nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" },
|
||||||
|
"nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
---@type vim.lsp.Config
|
||||||
|
return {
|
||||||
|
cmd = { "gopls" },
|
||||||
|
filetypes = { "go", "gomod", "gosum" },
|
||||||
|
root_markers = {
|
||||||
|
"go.mod",
|
||||||
|
"go.sum",
|
||||||
|
},
|
||||||
|
settings = {
|
||||||
|
gopls = {
|
||||||
|
analyses = {
|
||||||
|
unusedparams = true,
|
||||||
|
},
|
||||||
|
hints = {
|
||||||
|
assignVariableTypes = true,
|
||||||
|
compositeLiteralFields = true,
|
||||||
|
compositeLiteralTypes = true,
|
||||||
|
constantValues = true,
|
||||||
|
functionTypeParameters = true,
|
||||||
|
parameterNames = true,
|
||||||
|
rangeVariableTypes = true,
|
||||||
|
},
|
||||||
|
staticcheck = true,
|
||||||
|
gofumpt = true,
|
||||||
|
semanticTokens = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
local M = {
|
||||||
|
constants = {
|
||||||
|
big_file_size_limit = 50 * 1024, -- 50KB
|
||||||
|
},
|
||||||
|
servers = {
|
||||||
|
"lua_ls",
|
||||||
|
"gopls",
|
||||||
|
"clangd",
|
||||||
|
"bashls",
|
||||||
|
"pyright",
|
||||||
|
"yamlls",
|
||||||
|
"ts_ls",
|
||||||
|
},
|
||||||
|
tools = {
|
||||||
|
is_version_gte_0_11 = function()
|
||||||
|
local version = vim.version()
|
||||||
|
|
||||||
|
if version.major > 0 then
|
||||||
|
return true
|
||||||
|
elseif version.major == 0 then
|
||||||
|
return version.minor >= 11
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
|
@ -0,0 +1,22 @@
|
||||||
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
vim.fn.system({
|
||||||
|
"git",
|
||||||
|
"clone",
|
||||||
|
"--filter=blob:none",
|
||||||
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
|
"--branch=stable", -- latest stable release
|
||||||
|
lazypath,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
require("utils.plugins").setup()
|
||||||
|
|
||||||
|
require("lazy").setup({
|
||||||
|
spec = {
|
||||||
|
{ import = "plugins" },
|
||||||
|
},
|
||||||
|
install = { colorscheme = { "gruvbox" } },
|
||||||
|
checker = { enabled = false },
|
||||||
|
})
|
|
@ -0,0 +1,2 @@
|
||||||
|
local map = vim.keymap.set
|
||||||
|
map("n", "<leader>s", ":w<CR>", {})
|
|
@ -0,0 +1,125 @@
|
||||||
|
local cmd = vim.cmd
|
||||||
|
local opt = vim.opt
|
||||||
|
local g = vim.g
|
||||||
|
local s = vim.s
|
||||||
|
local indent = 4
|
||||||
|
|
||||||
|
g.mapleader = " "
|
||||||
|
|
||||||
|
cmd([[
|
||||||
|
filetype plugin indent on
|
||||||
|
]])
|
||||||
|
|
||||||
|
opt.backspace = { "eol", "start", "indent" } -- allow backspacing over everything in insert mode
|
||||||
|
-- opt.clipboard = "unnamedplus" -- allow neovim to access the system clipboard
|
||||||
|
vim.opt.fileencoding = "utf-8"
|
||||||
|
opt.encoding = "utf-8"
|
||||||
|
opt.matchpairs = { "(:)", "{:}", "[:]", "<:>" }
|
||||||
|
opt.syntax = "enable"
|
||||||
|
|
||||||
|
-- indention
|
||||||
|
opt.autoindent = true
|
||||||
|
opt.expandtab = true
|
||||||
|
opt.shiftwidth = indent
|
||||||
|
opt.smartindent = true
|
||||||
|
opt.softtabstop = indent
|
||||||
|
opt.tabstop = indent
|
||||||
|
opt.shiftround = true
|
||||||
|
|
||||||
|
-- search
|
||||||
|
opt.hlsearch = true
|
||||||
|
opt.ignorecase = true
|
||||||
|
opt.smartcase = true
|
||||||
|
opt.wildignore = opt.wildignore + { "*/node_modules/*", "*/.git/*", "*/vendor/*" }
|
||||||
|
opt.wildmenu = true
|
||||||
|
|
||||||
|
-- ui
|
||||||
|
opt.cursorline = true
|
||||||
|
opt.laststatus = 2
|
||||||
|
opt.lazyredraw = true
|
||||||
|
opt.list = true
|
||||||
|
opt.listchars = {
|
||||||
|
tab = "┊ ",
|
||||||
|
trail = "·",
|
||||||
|
extends = "»",
|
||||||
|
precedes = "«",
|
||||||
|
nbsp = "×",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Hide cmd line
|
||||||
|
opt.cmdheight = 0
|
||||||
|
|
||||||
|
opt.mouse = "a"
|
||||||
|
opt.number = true
|
||||||
|
opt.relativenumber = true
|
||||||
|
opt.scrolloff = 18
|
||||||
|
opt.sidescrolloff = 3
|
||||||
|
opt.signcolumn = "yes"
|
||||||
|
opt.splitbelow = true
|
||||||
|
opt.splitright = true
|
||||||
|
opt.wrap = false
|
||||||
|
|
||||||
|
-- backups
|
||||||
|
opt.backup = false -- create a backup file
|
||||||
|
opt.swapfile = false -- creates a swapfile
|
||||||
|
opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
|
||||||
|
|
||||||
|
-- autocomplete
|
||||||
|
opt.completeopt = { "menu", "menuone", "noselect" } -- mostly just for cmp
|
||||||
|
opt.shortmess = opt.shortmess + {
|
||||||
|
c = true,
|
||||||
|
} -- hide all the completion messages, e.g. "-- XXX completion (YYY)", "match 1 of 2", "The only match", "Pattern not found"
|
||||||
|
|
||||||
|
opt.showmode = false
|
||||||
|
|
||||||
|
-- perfomance
|
||||||
|
-- remember N lines in history
|
||||||
|
opt.history = 100 -- keep 100 lines of history
|
||||||
|
opt.redrawtime = 1500
|
||||||
|
opt.timeoutlen = 250 -- time to wait for a mapped sequence to complete (in milliseconds)
|
||||||
|
opt.ttimeoutlen = 10
|
||||||
|
opt.updatetime = 100 -- signify default updatetime 4000ms is not good for async update
|
||||||
|
|
||||||
|
-- theme
|
||||||
|
opt.termguicolors = true -- enable 24-bit RGB colors
|
||||||
|
|
||||||
|
-- persistent undo
|
||||||
|
-- Don"t forget to create folder $HOME/.local/share/nvim/undo
|
||||||
|
local undodir = vim.fn.stdpath("data") .. "/undo"
|
||||||
|
opt.undofile = true -- enable persistent undo
|
||||||
|
opt.undodir = undodir
|
||||||
|
opt.undolevels = 1000
|
||||||
|
opt.undoreload = 10000
|
||||||
|
|
||||||
|
-- fold
|
||||||
|
opt.foldmethod = "marker"
|
||||||
|
opt.foldlevel = 99
|
||||||
|
|
||||||
|
-- Disable builtin plugins
|
||||||
|
local disabled_built_ins = {
|
||||||
|
"2html_plugin",
|
||||||
|
"getscript",
|
||||||
|
"getscriptPlugin",
|
||||||
|
"gzip",
|
||||||
|
"logipat",
|
||||||
|
"netrw",
|
||||||
|
"netrwPlugin",
|
||||||
|
"netrwSettings",
|
||||||
|
"netrwFileHandlers",
|
||||||
|
"matchit",
|
||||||
|
"rrhelper",
|
||||||
|
"spellfile_plugin",
|
||||||
|
"vimball",
|
||||||
|
"vimballPlugin",
|
||||||
|
"tutor",
|
||||||
|
"rplugin",
|
||||||
|
"synmenu",
|
||||||
|
"optwin",
|
||||||
|
"compiler",
|
||||||
|
"bugreport",
|
||||||
|
"ftplugin",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, plugin in pairs(disabled_built_ins) do
|
||||||
|
g["loaded_" .. plugin] = 1
|
||||||
|
end
|
|
@ -0,0 +1,23 @@
|
||||||
|
if require("commons").tools.is_version_gte_0_11() then
|
||||||
|
for _, server in pairs(require("commons").servers) do
|
||||||
|
local ok, settings = pcall(require, "lsp." .. server)
|
||||||
|
if ok then
|
||||||
|
vim.lsp.config(server, settings)
|
||||||
|
end
|
||||||
|
vim.lsp.enable(server)
|
||||||
|
end
|
||||||
|
vim.diagnostic.config({
|
||||||
|
update_in_insert = true,
|
||||||
|
severity_sort = true,
|
||||||
|
float = { source = true },
|
||||||
|
virtual_text = true,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
local lsp = require("lspconfig")
|
||||||
|
for _,server in pairs(require("commons").servers) do
|
||||||
|
local ok,settings = pcall(require,"lsp."..server)
|
||||||
|
if ok then
|
||||||
|
lsp[server].setup(settings)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
return {
|
||||||
|
"windwp/nvim-autopairs",
|
||||||
|
event = "InsertEnter",
|
||||||
|
config = function()
|
||||||
|
local npairs = require("nvim-autopairs")
|
||||||
|
npairs.setup()
|
||||||
|
end,
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
local not_enabled_filetype = { "markdown" }
|
||||||
|
|
||||||
|
---@module 'blink.cmp'
|
||||||
|
---@type blink.cmp.Config
|
||||||
|
local opts = {
|
||||||
|
cmdline = { enabled = true },
|
||||||
|
keymap = { preset = "super-tab" },
|
||||||
|
completion = {
|
||||||
|
documentation = {
|
||||||
|
auto_show = true,
|
||||||
|
treesitter_highlighting = true,
|
||||||
|
},
|
||||||
|
keyword = {
|
||||||
|
range = "prefix",
|
||||||
|
},
|
||||||
|
list = {
|
||||||
|
selection = {
|
||||||
|
preselect = true,
|
||||||
|
auto_insert = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
accept = {
|
||||||
|
dot_repeat = false,
|
||||||
|
create_undo_point = true,
|
||||||
|
auto_brackets = { enabled = true },
|
||||||
|
},
|
||||||
|
menu = {
|
||||||
|
draw = {
|
||||||
|
columns = { { "label", "label_detail", gap = 1 }, { "kind_icon", "kind", gap = 1 } },
|
||||||
|
components = {
|
||||||
|
label = {
|
||||||
|
width = { max = 30, fill = true },
|
||||||
|
text = function(ctx)
|
||||||
|
return ctx.label
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
label_detail = {
|
||||||
|
width = { fill = true, max = 15 },
|
||||||
|
text = function(ctx)
|
||||||
|
return ctx.label_detail
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
source_name = {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
appearance = {
|
||||||
|
nerd_font_variant = "mono",
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
default = { "lsp", "path", "snippets", "buffer" },
|
||||||
|
providers = {
|
||||||
|
buffer = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
snippets = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fuzzy = {
|
||||||
|
implementation = "rust",
|
||||||
|
use_frecency = false,
|
||||||
|
use_proximity = false,
|
||||||
|
max_typos = function(_)
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
prebuilt_binaries = {
|
||||||
|
download = false,
|
||||||
|
ignore_version_mismatch = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
signature = { enabled = true },
|
||||||
|
}
|
||||||
|
|
||||||
|
local setup = function(_, opts)
|
||||||
|
return opts
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
opts_extend = { "sources.completion.enabled_providers", "sources.compat", "sources.default" },
|
||||||
|
dependencies = {
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
{ "saghen/blink.compat", optional = true, opts = {}, version = not vim.g.lazyvim_blink_main and "*" },
|
||||||
|
},
|
||||||
|
event = "InsertEnter",
|
||||||
|
version = "*",
|
||||||
|
enabled = function()
|
||||||
|
return not vim.tbl_contains(not_enabled_filetype, vim.bo.filetype)
|
||||||
|
and vim.bo.buftype ~= "prompt"
|
||||||
|
and vim.b.completion ~= false
|
||||||
|
end,
|
||||||
|
opts = opts,
|
||||||
|
config = setup,
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
return {
|
||||||
|
"ellisonleao/gruvbox.nvim",
|
||||||
|
priority = 1000,
|
||||||
|
lazy = false,
|
||||||
|
config = function()
|
||||||
|
require("gruvbox").setup({
|
||||||
|
italic = {
|
||||||
|
strings = false,
|
||||||
|
operators = false,
|
||||||
|
folds = false,
|
||||||
|
emphasis = false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
vim.cmd.colorscheme("gruvbox")
|
||||||
|
end,
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
return {
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
lazy = true,
|
||||||
|
cmd = "ConformInfo",
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>ff",
|
||||||
|
function()
|
||||||
|
require("conform").format()
|
||||||
|
end,
|
||||||
|
mode = { "n", "v" },
|
||||||
|
desc = "Use Conform to format current buffer",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
default_format_opts = {
|
||||||
|
timeout_ms = 3000,
|
||||||
|
async = false,
|
||||||
|
quiet = false,
|
||||||
|
lsp_format = "fallback",
|
||||||
|
},
|
||||||
|
formatters_by_ft = {
|
||||||
|
lua = { "stylua" },
|
||||||
|
python = { "black" },
|
||||||
|
rust = { "rustfmt" },
|
||||||
|
javascript = { "prettier", stop_after_first = true },
|
||||||
|
sh = { "shfmt" },
|
||||||
|
},
|
||||||
|
formatters = { injected = { options = { ignore_errors = true } } },
|
||||||
|
format_on_save = { timeout_ms = 500, lsp_format = "fallback" },
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
return {
|
||||||
|
"lewis6991/gitsigns.nvim",
|
||||||
|
key = {},
|
||||||
|
opts = {
|
||||||
|
current_line_blame = true,
|
||||||
|
current_line_blame_opts = {delay = 100},
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
return {
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
-- cond = not require("commons").tools.is_version_gte_0_11(),
|
||||||
|
dependencies = { { "saghen/blink.cmp" } },
|
||||||
|
config = function()
|
||||||
|
end,
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
return {
|
||||||
|
"mason-org/mason.nvim",
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
return {
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
version = "*",
|
||||||
|
lazy = false,
|
||||||
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>n",
|
||||||
|
":NvimTreeToggle<CR>",
|
||||||
|
mode = { "n" },
|
||||||
|
desc = "Use Conform to format current buffer",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
vim.g.loaded_netrw = 1
|
||||||
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
|
require("nvim-tree").setup({
|
||||||
|
diagnostics = {
|
||||||
|
enable = true,
|
||||||
|
show_on_dirs = true,
|
||||||
|
},
|
||||||
|
filters = {
|
||||||
|
git_ignored = false,
|
||||||
|
},
|
||||||
|
renderer = {
|
||||||
|
indent_markers = { enable = true },
|
||||||
|
},
|
||||||
|
view = {
|
||||||
|
number = true,
|
||||||
|
relativenumber = true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
return {
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
build = function()
|
||||||
|
require("nvim-treesitter.install").update({ with_sync = true })()
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
local configs = require("nvim-treesitter.configs")
|
||||||
|
configs.setup({
|
||||||
|
ensure_installed = {
|
||||||
|
'html',
|
||||||
|
'json',
|
||||||
|
'cmake',
|
||||||
|
'make',
|
||||||
|
'python',
|
||||||
|
'go',
|
||||||
|
'rust',
|
||||||
|
'yaml',
|
||||||
|
'bash'
|
||||||
|
},
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
disable = function(lang,buf)
|
||||||
|
local ok,stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||||
|
if ok and stats and stats.size > require("commons").constants.big_file_size_limit then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
incremental_selection = {enable = true},
|
||||||
|
indent = {enable = true},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
return {
|
||||||
|
"folke/which-key.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {
|
||||||
|
spec = {
|
||||||
|
{"<BS>", desc = "Decrement Selection", mode = "x"},
|
||||||
|
{"<c-space>", desc = "Increment Selection", mode = {"x", "n"}}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>?",
|
||||||
|
function() require("which-key").show({global = false}) end,
|
||||||
|
desc = "Buffer Local Keymaps (which-key)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" }
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
M.lazy_file()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.lazy_file()
|
||||||
|
local Event = require("lazy.core.handler.event")
|
||||||
|
|
||||||
|
Event.mappings.LazyFile = {id = "LazyFile", event = M.lazy_file_events}
|
||||||
|
Event.mappings["User LazyFile"] = Event.mappings.LazyFile
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
Reference in New Issue