save
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
vim.g.mapleader = " "
|
||||
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.swapfile = false
|
||||
@@ -5,70 +7,139 @@ vim.opt.wrap = false
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
for _, k in ipairs({ "h", "j", "k", "l" }) do
|
||||
vim.keymap.set({ "n", "i", "v" }, "<C-" .. k .. ">", "<C-w><C-" .. k .. ">")
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<Esc>", ":nohlsearch<CR>")
|
||||
vim.keymap.set("n", "<leader>en", ":edit $MYVIMRC<CR>")
|
||||
vim.keymap.set("n", "<leader>ez", ":edit ~/.zshrc<CR>")
|
||||
|
||||
vim.pack.add {
|
||||
{ src = "https://github.com/nvim-lua/plenary.nvim" },
|
||||
{ src = "https://github.com/nvim-telescope/telescope.nvim" },
|
||||
{ src = "https://github.com/nvim-telescope/telescope-ui-select.nvim" },
|
||||
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
||||
{ src = "https://github.com/blazkowolf/gruber-darker.nvim" },
|
||||
}
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
local telescope = require("telescope")
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
preview = { treesitter = false },
|
||||
color_devicons = true,
|
||||
sorting_strategy = "ascending",
|
||||
borderchars = {
|
||||
"─", -- top
|
||||
"│", -- right
|
||||
"─", -- bottom
|
||||
"│", -- left
|
||||
"┌", -- top-left
|
||||
"┐", -- top-right
|
||||
"┘", -- bottom-right
|
||||
"└", -- bottom-left
|
||||
},
|
||||
path_displays = { "smart" },
|
||||
layout_config = {
|
||||
height = 100,
|
||||
width = 400,
|
||||
prompt_position = "top",
|
||||
preview_cutoff = 40,
|
||||
}
|
||||
}
|
||||
})
|
||||
telescope.load_extension("ui-select")
|
||||
for _, k in ipairs({ "h", "j", "k", "l" }) do
|
||||
vim.keymap.set({ "n", "i", "v" }, "<C-" .. k .. ">", "<C-w><C-" .. k .. ">")
|
||||
end
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>sf', builtin.find_files)
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep)
|
||||
vim.keymap.set('n', '<leader>sb', builtin.buffers)
|
||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags)
|
||||
vim.keymap.set('n', '<leader>sm', builtin.man_pages)
|
||||
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",
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "c", "cpp", "h", "hpp" },
|
||||
callback = function()
|
||||
vim.lsp.start {
|
||||
name = "clangd",
|
||||
cmd = { "clangd", "--background-index", "--clang-tidy", "--completion-style=detailed", "--header-insertion=iwyu" },
|
||||
root_dir = vim.fs.dirname(vim.fs.find({ ".git", "Makefile", "makefile", "README" }, { upward = true })[1]),
|
||||
}
|
||||
require("lazy").setup({
|
||||
{
|
||||
"blazkowolf/gruber-darker.nvim",
|
||||
priority = 1000,
|
||||
config = function()
|
||||
vim.cmd.colorscheme("gruber-darker")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
build = ":MasonUpdate",
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
dependencies = { "williamboman/mason.nvim", "neovim/nvim-lspconfig" },
|
||||
config = function()
|
||||
local ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||
local capabilities = ok and cmp_nvim_lsp.default_capabilities() or
|
||||
vim.lsp.protocol.make_client_capabilities()
|
||||
|
||||
local servers = { "lua_ls", "clangd", "pyright", "gopls" }
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = servers,
|
||||
})
|
||||
|
||||
for _, name in ipairs(servers) do
|
||||
local cfg = { capabilities = capabilities }
|
||||
|
||||
if name == "lua_ls" then
|
||||
cfg.settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } },
|
||||
workspace = { library = vim.api.nvim_get_runtime_file("", true) },
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
local server_cfg = vim.lsp.config[name]
|
||||
if not server_cfg then
|
||||
vim.notify("LSP server config not found: " .. name, vim.log.levels.WARN)
|
||||
else
|
||||
local cmd = server_cfg.cmd or { name }
|
||||
vim.lsp.start(vim.tbl_extend("force", cfg, {
|
||||
name = name,
|
||||
cmd = cmd,
|
||||
root_dir = vim.fs.root(0, { ".git", "Makefile", "main.c", "go.mod" }),
|
||||
settings = cfg.settings,
|
||||
}))
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
cmp.setup({
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
priority = 1000,
|
||||
lazy = false,
|
||||
opts = {
|
||||
bigfile = { enabled = true },
|
||||
picker = { enabled = true },
|
||||
quickfile = { enabled = true },
|
||||
terminal = {
|
||||
enabled = true,
|
||||
float = {
|
||||
border = "rounded",
|
||||
width = 0.8,
|
||||
height = 0.8,
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("snacks").setup(opts)
|
||||
vim.keymap.set("n", "<C-_>", function()
|
||||
require("snacks.terminal").toggle(nil, { float = true })
|
||||
end)
|
||||
vim.keymap.set("t", "<C-_>", function()
|
||||
require("snacks.terminal").toggle(nil, { float = true })
|
||||
end)
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
vim.diagnostic.config { virtual_text = true, underline = true, signs = false }
|
||||
|
||||
vim.cmd.colorscheme("gruber-darker")
|
||||
|
||||
12
nvim/.config/nvim/lazy-lock.json
Normal file
12
nvim/.config/nvim/lazy-lock.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
|
||||
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||
"gruber-darker.nvim": { "branch": "main", "commit": "98a2e141981cbd5a194a97eae024bf55af854579" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "e6a8824858757ca9cd4f5ae1a72d845fa5c46a39" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "d7b5feb6e769e995f7fcf44d92f49f811c51d10c" },
|
||||
"mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "106c4bcc053a5da783bf4a9d907b6f22485c2ea0" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "2010fc6ec03e2da552b4886fceb2f7bc0fc2e9c0" },
|
||||
"snacks.nvim": { "branch": "main", "commit": "6121b40a2d2fc07beee040209d59e579aad51d98" }
|
||||
}
|
||||
Reference in New Issue
Block a user