new nvim conf
This commit is contained in:
1
nvim/.config/nvim/ftplugin/text.lua
Normal file
1
nvim/.config/nvim/ftplugin/text.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vim.opt.wrap = true
|
||||||
@@ -1,167 +1,4 @@
|
|||||||
vim.g.mapleader = " "
|
require 'plugins'
|
||||||
|
require 'configs'
|
||||||
vim.opt.number = true
|
require 'lsp'
|
||||||
vim.opt.relativenumber = true
|
require 'keymaps'
|
||||||
vim.opt.swapfile = false
|
|
||||||
vim.opt.wrap = false
|
|
||||||
vim.opt.splitright = true
|
|
||||||
vim.opt.splitbelow = true
|
|
||||||
|
|
||||||
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.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
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
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" }
|
|
||||||
|
|
||||||
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-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 = "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,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'nvim-telescope/telescope.nvim',
|
|
||||||
tag = '0.1.8',
|
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
|
||||||
config = function()
|
|
||||||
local builtin = require("telescope.builtin")
|
|
||||||
require("telescope").setup {}
|
|
||||||
vim.keymap.set("n", "<leader>g", builtin.live_grep)
|
|
||||||
vim.keymap.set("n", "<leader>f", builtin.find_files)
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"https://github.com/tpope/vim-fugitive"
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
|
||||||
pattern = 'python',
|
|
||||||
callback = function()
|
|
||||||
vim.bo.expandtab = false
|
|
||||||
vim.bo.shiftwidth = 4
|
|
||||||
vim.bo.tabstop = 4
|
|
||||||
vim.bo.softtabstop = 4
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.diagnostic.config { virtual_text = true, underline = true, signs = false }
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"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": "85c7ff3711b730b4030d03144f6db6375044ae82" },
|
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "f760507df8c49a4bf46a4d12e1fc616797508979" },
|
|
||||||
"mason.nvim": { "branch": "main", "commit": "b3689a41dd77e5294498dba9757fb22cc80cbebd" },
|
|
||||||
"nvim-cmp": { "branch": "main", "commit": "106c4bcc053a5da783bf4a9d907b6f22485c2ea0" },
|
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "336b388c272555d2ae94627a50df4c2f89a5e257" },
|
|
||||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
|
||||||
"snacks.nvim": { "branch": "main", "commit": "5e0e8698526f350f1280ad1ef7a8670f857c9445" },
|
|
||||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
|
||||||
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }
|
|
||||||
}
|
|
||||||
11
nvim/.config/nvim/lsp/bashls.lua
Normal file
11
nvim/.config/nvim/lsp/bashls.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---@type vim.lsp.Config
|
||||||
|
return {
|
||||||
|
cmd = { 'bash-language-server', 'start' },
|
||||||
|
settings = {
|
||||||
|
bashIde = {
|
||||||
|
globPattern = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filetypes = { 'bash', 'sh' },
|
||||||
|
root_markers = { '.git' },
|
||||||
|
}
|
||||||
6
nvim/.config/nvim/lsp/clangd.lua
Normal file
6
nvim/.config/nvim/lsp/clangd.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---@type vim.lsp.Config
|
||||||
|
return {
|
||||||
|
cmd = { 'clangd' },
|
||||||
|
filetypes = { 'c', 'h' },
|
||||||
|
root_markers = { 'Makefile', '.git' },
|
||||||
|
}
|
||||||
6
nvim/.config/nvim/lsp/gopls.lua
Normal file
6
nvim/.config/nvim/lsp/gopls.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---@type vim.lsp.Config
|
||||||
|
return {
|
||||||
|
cmd = { 'gopls' },
|
||||||
|
filetypes = { 'go', 'gomod', 'gosum' },
|
||||||
|
root_markers = { 'go.mod', 'go.sum' },
|
||||||
|
}
|
||||||
34
nvim/.config/nvim/lsp/lua_ls.lua
Normal file
34
nvim/.config/nvim/lsp/lua_ls.lua
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---@type vim.lsp.Config
|
||||||
|
return {
|
||||||
|
cmd = { 'lua-language-server' },
|
||||||
|
filetypes = { 'lua' },
|
||||||
|
root_markers = {
|
||||||
|
'.luarc.json',
|
||||||
|
'.luarc.jsonc',
|
||||||
|
'.luacheckrc',
|
||||||
|
'.stylua.toml',
|
||||||
|
'stylua.toml',
|
||||||
|
'selene.toml',
|
||||||
|
'selene.yml',
|
||||||
|
'.git',
|
||||||
|
},
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
version = "Lua 5.4",
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
enable = true,
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
library = { vim.env.VIMRUNTIME },
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
8
nvim/.config/nvim/lua/configs.lua
Normal file
8
nvim/.config/nvim/lua/configs.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
local opt = vim.opt
|
||||||
|
|
||||||
|
opt.number = true
|
||||||
|
opt.relativenumber = true
|
||||||
|
opt.swapfile = false
|
||||||
|
opt.wrap = false
|
||||||
|
opt.splitright = true
|
||||||
|
opt.splitbelow = true
|
||||||
12
nvim/.config/nvim/lua/keymaps.lua
Normal file
12
nvim/.config/nvim/lua/keymaps.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
local keymap = vim.keymap.set
|
||||||
|
|
||||||
|
keymap("n", "<Esc>", ":nohlsearch<CR>")
|
||||||
|
keymap("n", "<leader>en", ":edit $MYVIMRC<CR>")
|
||||||
|
keymap("n", "<leader>ez", ":edit ~/.zshrc<CR>")
|
||||||
|
|
||||||
|
keymap("v", "J", ":m '>+1<CR>gv=gv")
|
||||||
|
keymap("v", "K", ":m '<-2<CR>gv=gv")
|
||||||
|
|
||||||
|
for _, k in ipairs({ "h", "j", "k", "l" }) do
|
||||||
|
keymap({ "n", "i", "v" }, "<C-" .. k .. ">", "<C-w><C-" .. k .. ">")
|
||||||
|
end
|
||||||
8
nvim/.config/nvim/lua/lsp.lua
Normal file
8
nvim/.config/nvim/lua/lsp.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
vim.lsp.enable {
|
||||||
|
"bashls",
|
||||||
|
"gopls",
|
||||||
|
"lua_ls",
|
||||||
|
"clangd",
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.diagnostic.config { virtual_text = true, underline = true, signs = false }
|
||||||
10
nvim/.config/nvim/lua/plugins.lua
Normal file
10
nvim/.config/nvim/lua/plugins.lua
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
vim.pack.add {
|
||||||
|
{ src = "https://github.com/mason-org/mason.nvim" },
|
||||||
|
{ src = "https://github.com/scottmckendry/cyberdream.nvim" },
|
||||||
|
}
|
||||||
|
|
||||||
|
require("mason").setup {}
|
||||||
|
|
||||||
|
vim.cmd("colorscheme cyberdream")
|
||||||
16
nvim/.config/nvim/nvim-pack-lock.json
Normal file
16
nvim/.config/nvim/nvim-pack-lock.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"plugins": {
|
||||||
|
"cyberdream.nvim": {
|
||||||
|
"rev": "a43b45423e8494898c353c0604e0b2e4e99bd056",
|
||||||
|
"src": "https://github.com/scottmckendry/cyberdream.nvim"
|
||||||
|
},
|
||||||
|
"mason.nvim": {
|
||||||
|
"rev": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800",
|
||||||
|
"src": "https://github.com/mason-org/mason.nvim"
|
||||||
|
},
|
||||||
|
"simplyfile.nvim": {
|
||||||
|
"rev": "c4dfc0f3431898c3abbef267b226f6cdd2a67b38",
|
||||||
|
"src": "https://github.com/Rizwanelansyah/simplyfile.nvim"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user