Created
May 17, 2025 02:41
-
-
Save nonrice/3395bfbfff8dedd2859f5dd66cf5e35c to your computer and use it in GitHub Desktop.
nvim conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim.o.number = true | |
vim.o.relativenumber = true | |
vim.o.cursorline = true | |
vim.o.lbr = true | |
vim.o.wrap = true | |
vim.o.hlsearch = true | |
vim.schedule(function() | |
vim.o.clipboard = "unnamedplus" | |
end) | |
vim.o.smartindent = true | |
vim.o.autoindent = true | |
vim.o.expandtab = true | |
vim.o.shiftwidth = 4 | |
vim.o.tabstop = 4 | |
vim.o.softtabstop = 4 | |
vim.o.list = true | |
vim.opt.listchars = { tab = "» ", trail = "·" } | |
vim.o.scrolloff = 10 | |
vim.o.signcolumn = "yes" | |
vim.keymap.set("n", "<C-a>", '<cmd>%y"<cr>', { desc = "Yank whole file" }) | |
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) | |
vim.g.mapleader = " " | |
vim.g.maplocalleader = "\\" | |
require("lazy").setup({ | |
spec = { | |
{ | |
"neanias/everforest-nvim", | |
lazy = false, | |
priority = 1000, | |
opts = { | |
background = "soft", | |
}, | |
config = function(_, opts) | |
require("everforest").setup(opts) | |
vim.cmd("colorscheme everforest") | |
end, | |
}, | |
{ | |
"nvim-treesitter/nvim-treesitter", | |
build = ":TSUpdate", | |
config = function(_, opts) | |
require("nvim-treesitter.configs").setup({ | |
highlight = { | |
enable = true, | |
}, | |
}) | |
end, | |
}, | |
{ | |
"tpope/vim-sleuth", | |
}, | |
{ | |
"windwp/nvim-autopairs", | |
event = "InsertEnter", | |
config = true, | |
}, | |
{ | |
"folke/which-key.nvim", | |
}, | |
{ | |
"nvim-lualine/lualine.nvim", | |
opts = { | |
options = { | |
component_separators = "", | |
section_separators = { left = "", right = "" }, | |
}, | |
}, | |
}, | |
{ | |
"nvim-tree/nvim-tree.lua", | |
keys = { | |
{ "<leader>tt", "<cmd>NvimTreeToggle<cr>", desc = "Toggle tree" }, | |
{ "<leader>tf", "<cmd>NvimTreeFocus<cr>", desc = "Focus on tree" }, | |
}, | |
opts = {}, | |
config = function(_, opts) | |
require("nvim-tree").setup(opts) | |
end, | |
}, | |
{ | |
"mason-org/mason.nvim", | |
dependencies = { | |
"mason-org/mason-lspconfig.nvim", | |
"neovim/nvim-lspconfig", | |
}, | |
config = function() | |
require("mason").setup() | |
require("mason-lspconfig").setup({ | |
ensure_installed = { | |
"clangd", | |
}, | |
automatic_enable = true, | |
}) | |
vim.api.nvim_create_autocmd("LspAttach", { | |
group = vim.api.nvim_create_augroup("my.lsp", {}), | |
callback = function(args) | |
local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) | |
if client:supports_method("textDocument/rename") then | |
vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, { desc = "Rename symbol" }) | |
end | |
if client:supports_method("textDocument/hover") then | |
vim.keymap.set("n", "<leader>lh", vim.lsp.buf.hover, { desc = "Show hover doc" }) | |
end | |
if client:supports_method("textDocument/references") then | |
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.references, { desc = "List references" }) | |
end | |
vim.diagnostic.config({ | |
virtual_text = true, | |
}) | |
end, | |
}) | |
vim.lsp.config("*", { | |
root_markers = { ".git" }, | |
}) | |
--[[ | |
vim.lsp.config("clangd", { | |
cmd = { "/usr/bin/clangd" }, | |
}) | |
--]] | |
vim.lsp.config("lua_ls", { | |
settings = { | |
Lua = { | |
diagnostics = { | |
globals = { "vim" }, | |
}, | |
}, | |
}, | |
}) | |
end, | |
}, | |
{ | |
"stevearc/conform.nvim", | |
event = "InsertEnter", | |
opts = { | |
format_on_save = { | |
timeout_ms = 500, | |
lsp_fallback = true, -- use LSP formatting if no formatter is found | |
}, | |
formatters_by_ft = { | |
lua = { "stylua" }, | |
}, | |
}, | |
}, | |
{ | |
"L3MON4D3/LuaSnip", | |
event = "InsertEnter", | |
version = "v2.*", | |
config = function() | |
require("luasnip.loaders.from_snipmate").lazy_load({ | |
paths = { "./snippets/cp" }, | |
}) | |
require("luasnip.loaders.from_snipmate").lazy_load() | |
end, | |
}, | |
{ | |
"hrsh7th/nvim-cmp", | |
event = "InsertEnter", | |
dependencies = { | |
"hrsh7th/cmp-nvim-lsp", | |
"L3MON4D3/LuaSnip", | |
"saadparwaiz1/cmp_luasnip", | |
}, | |
config = function() | |
local cmp = require("cmp") | |
cmp.setup({ | |
snippet = { | |
expand = function(args) | |
require("luasnip").lsp_expand(args.body) | |
end, | |
}, | |
mapping = cmp.mapping.preset.insert({ | |
["<tab>"] = cmp.mapping.confirm({ select = true }), | |
}), | |
sources = { | |
{ name = "nvim_lsp" }, | |
{ name = "luasnip" }, | |
}, | |
}) | |
end, | |
}, | |
{ | |
"nvim-telescope/telescope.nvim", | |
tag = "0.1.8", | |
dependencies = { "nvim-lua/plenary.nvim" }, | |
keys = { | |
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Telescope find files" }, | |
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Telescope live grep" }, | |
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Telescope buffers" }, | |
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "Telescope help tags" }, | |
}, | |
opts = {}, | |
config = function(_, opts) | |
require("telescope").load_extension("luasnip") | |
end, | |
}, | |
{ | |
"benfowler/telescope-luasnip.nvim", | |
module = "telescope._extensions.luasnip", -- if you wish to lazy-load | |
opts = {}, | |
}, | |
{ | |
"xeluxee/competitest.nvim", | |
dependencies = { "MunifTanjim/nui.nvim" }, | |
opts = { | |
floating_border = "single", | |
runner_ui = { | |
mappings = { | |
kill = "<C-c>", | |
}, | |
}, | |
popup_ui = { | |
total_width = 0.9, | |
total_height = 0.9, | |
layout = { | |
{ | |
1, | |
{ | |
{ 1, "tc" }, | |
{ 1, "si" }, | |
}, | |
}, | |
{ | |
1, | |
{ | |
{ 1, "so" }, | |
{ 1, "eo" }, | |
}, | |
}, | |
{ | |
2, | |
{ | |
{ 1, "se" }, | |
}, | |
}, | |
}, | |
}, | |
compile_command = { | |
cpp = { | |
exec = "clang++", | |
args = { | |
"$(FNAME)", | |
"-std=c++17", | |
"-Wall", | |
"-Wextra", | |
"-Wpedantic", | |
"-Wshadow", | |
"-Wshift-overflow", | |
"-D_GLIBCXX_DEBUG", | |
"-D_GLIBCXX_DEBUG_PEDANTIC", | |
"-DLOCAL", | |
"-fsanitize=address,undefined", | |
"-fsanitize-address-use-after-scope", | |
"-g", | |
"-o", | |
"$(FNOEXT)", | |
}, | |
}, | |
}, | |
}, | |
keys = { | |
{ "<leader>er", "<cmd>CompetiTest run<cr>", desc = "Run tests" }, | |
{ "<leader>ee", "<cmd>CompetiTest edit_testcase<cr>", desc = "Edit tests" }, | |
{ "<leader>et", "<cmd>CompetiTest add_testcase<cr>", desc = "Add test" }, | |
{ "<leader>ecp", "<cmd>CompetiTest receive problem<cr>", desc = "Receive problem" }, | |
{ "<leader>ect", "<cmd>CompetiTest receive testcases<cr>", desc = "Receive tests" }, | |
{ "<leader>ecc", "<cmd>CompetiTest receive contest<cr>", desc = "Receive contest" }, | |
}, | |
config = function(_, opts) | |
require("competitest").setup(opts) | |
end, | |
}, | |
}, | |
checker = { enabled = true }, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment