parent
a5693c1964
commit
69286972bf
40 changed files with 41 additions and 744 deletions
75
nvim/init.lua
Normal file
75
nvim/init.lua
Normal file
|
@ -0,0 +1,75 @@
|
|||
require("plugin_specs")
|
||||
|
||||
local keymap = vim.keymap
|
||||
local opt = vim.opt
|
||||
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
vim.opt.termguicolors = true
|
||||
require("nvim-tree").setup()
|
||||
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
theme = "auto",
|
||||
icons_enabled = true,
|
||||
globalstatus = true,
|
||||
}
|
||||
}
|
||||
|
||||
require("gitsigns").setup()
|
||||
|
||||
opt.tabstop = 2
|
||||
opt.softtabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.expandtab = true
|
||||
opt.relativenumber = true
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.scrolloff = 3
|
||||
opt.confirm = true
|
||||
opt.history = 500
|
||||
opt.undofile = true
|
||||
opt.termguicolors = true
|
||||
opt.showmode = false
|
||||
opt.mouse = ""
|
||||
|
||||
vim.cmd.colorscheme "tokyonight-night"
|
||||
|
||||
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
|
||||
desc = "toggle nvim-tree",
|
||||
silent = true,
|
||||
})
|
||||
|
||||
-- shortcut to command mode
|
||||
keymap.set({ "n", "x" }, ";", ":", { silent = true })
|
||||
|
||||
keymap.set("n", [[\d]], "<cmd>close<cr>", {
|
||||
silent = true,
|
||||
})
|
||||
|
||||
keymap.set("n", "<space>o", "printf('m`%so<ESC>``', v:count1)", {
|
||||
expr = true,
|
||||
desc = "insert line below without moving cursor",
|
||||
})
|
||||
|
||||
keymap.set("n", "<space>O", "printf('m`%sO<ESC>``', v:count1)", {
|
||||
expr = true,
|
||||
desc = "insert line above without moving cursor",
|
||||
})
|
||||
|
||||
keymap.set("n", "/", [[/\v]])
|
||||
|
||||
keymap.set("n", "c", '"_c')
|
||||
keymap.set("n", "C", '"_C')
|
||||
keymap.set("n", "cc", '"_cc')
|
||||
keymap.set("x", "c", '"_c')
|
||||
keymap.set("x", "p", '"_c<Esc>p')
|
||||
|
||||
-- Break inserted text into smaller undo units when we insert some punctuation chars.
|
||||
local undo_ch = { ",", ".", "!", "?", ";", ":" }
|
||||
for _, ch in ipairs(undo_ch) do
|
||||
keymap.set("i", ch, ch .. "<c-g>u")
|
||||
end
|
||||
|
||||
keymap.set("i", "<C-A>", "<HOME>")
|
||||
keymap.set("i", "<C-E>", "<END>")
|
22
nvim/lazy-lock.json
Normal file
22
nvim/lazy-lock.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-nvim-ultisnips": { "branch": "main", "commit": "2be0eda0f7fbf47ebd9fbdace369cc45d57acf49" },
|
||||
"cmp-omni": { "branch": "main", "commit": "4ef610bbd85a5ee4e97e09450c0daecbdc60de86" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" },
|
||||
"fzf-lua": { "branch": "main", "commit": "ce1e24f2a48089b65deefcb0a71a9856839002b5" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "ee7634ab4f0a6606438fe13e16cbf2065589a5ed" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "28b205ebe73a18f401e040585106f9bafd8ff21f" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "14039337a563f4efd72831888f332a15585f0ea1" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "00d219068385a4aa80859d4606ad6e03af6faa83" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "2e1daa1d164ad8cc3e99b44ca68e990888a66038" },
|
||||
"ultisnips": { "branch": "master", "commit": "49dc8cb2086db19d385791c8e1635723b0fd95c7" },
|
||||
"vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" },
|
||||
"vim-snippets": { "branch": "master", "commit": "f0a3184d9f90b96b044d5914625a25c554d7f301" }
|
||||
}
|
21
nvim/lua/config/fzf.lua
Normal file
21
nvim/lua/config/fzf.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
local keymap = vim.keymap
|
||||
|
||||
local fzf = require("fzf-lua")
|
||||
|
||||
keymap.set("n", "<leader>ff", fzf.files, { silent = true })
|
||||
keymap.set("n", "<leader>fr", fzf.oldfiles, { silent = true })
|
||||
keymap.set("n", "<leader>fc", fzf.resume, { silent = true })
|
||||
keymap.set("n", "<leader>fs", fzf.treesitter, { silent = true })
|
||||
keymap.set("n", "<leader>fg", fzf.grep_project, { silent = true })
|
||||
|
||||
fzf.setup {
|
||||
"fzf-native",
|
||||
keymap = {
|
||||
fzf = {
|
||||
["ctrl-u"] = "half-page-up",
|
||||
["ctrl-d"] = "half-page-down",
|
||||
["ctrl-j"] = "preview-page-down",
|
||||
["ctrl-k"] = "preview-page-up",
|
||||
}
|
||||
}
|
||||
}
|
72
nvim/lua/config/lsp.lua
Normal file
72
nvim/lua/config/lsp.lua
Normal file
|
@ -0,0 +1,72 @@
|
|||
local lsp = vim.lsp
|
||||
local diagnostic = vim.diagnostic
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "gd", lsp.buf.definition)
|
||||
keymap.set("n", "<space>rn", lsp.buf.rename)
|
||||
keymap.set("n", "gr", lsp.buf.references)
|
||||
keymap.set("n", "[d", diagnostic.goto_prev)
|
||||
keymap.set("n", "]d", diagnostic.goto_next)
|
||||
|
||||
diagnostic.config {
|
||||
signs = false,
|
||||
}
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
lspconfig.pylsp.setup { capabilities = capabilities }
|
||||
lspconfig.clangd.setup { capabilities = capabilities }
|
||||
lspconfig.vimls.setup { capabilities = capabilities }
|
||||
lspconfig.bashls.setup { capabilities = capabilities }
|
||||
lspconfig.rust_analyzer.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.gopls.setup {
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
gofumpt = true,
|
||||
}
|
||||
},
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities,
|
||||
on_init = function(client)
|
||||
if client.workspace_folders then
|
||||
local path = client.workspace_folders[1].name
|
||||
if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using
|
||||
-- (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
-- Depending on the usage, you might want to add additional paths here.
|
||||
-- "${3rd}/luv/library"
|
||||
-- "${3rd}/busted/library",
|
||||
}
|
||||
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
|
||||
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||
}
|
||||
})
|
||||
end,
|
||||
settings = {
|
||||
Lua = {}
|
||||
}
|
||||
}
|
36
nvim/lua/config/nvim-cmp.lua
Normal file
36
nvim/lua/config/nvim-cmp.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["UltiSnips#Anon"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<Tab>"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<S-Tab"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||
},
|
||||
sources = cmp.config.sources {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "ultisnips" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}
|
||||
}
|
87
nvim/lua/plugin_specs.lua
Normal file
87
nvim/lua/plugin_specs.lua
Normal file
|
@ -0,0 +1,87 @@
|
|||
-- 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)
|
||||
|
||||
vim.g.mapleader = ","
|
||||
|
||||
local plugin_specs = {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
event = "VeryLazy",
|
||||
},
|
||||
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufRead", "BufNewFile" },
|
||||
config = function()
|
||||
require("config.lsp")
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = 'VeryLazy',
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-omni",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"quangnguyen30192/cmp-nvim-ultisnips",
|
||||
},
|
||||
config = function()
|
||||
require("config.nvim-cmp")
|
||||
end,
|
||||
},
|
||||
|
||||
{ "SirVer/ultisnips", dependencies = {
|
||||
"honza/vim-snippets",
|
||||
}, event = "InsertEnter" },
|
||||
|
||||
{ "stevearc/dressing.nvim", event = "VeryLazy" },
|
||||
|
||||
{
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
lazy = false,
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("config.fzf")
|
||||
end,
|
||||
},
|
||||
|
||||
{ "windwp/nvim-autopairs", event = "InsertEnter", config = true },
|
||||
|
||||
{ "tpope/vim-commentary", event = "VeryLazy" },
|
||||
|
||||
{ "folke/tokyonight.nvim", lazy = false, priority = 1000 },
|
||||
|
||||
{ "lewis6991/gitsigns.nvim"},
|
||||
|
||||
{ "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" } },
|
||||
}
|
||||
|
||||
require("lazy").setup({
|
||||
spec = plugin_specs,
|
||||
rocks = { enabled = true },
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue