added LSP and treesitter
This commit is contained in:
@@ -7,6 +7,7 @@ opt.laststatus = 2
|
||||
opt.termguicolors = true
|
||||
opt.autoread = true
|
||||
opt.mouse = "a"
|
||||
opt.clipboard:append("unnamedplus")
|
||||
opt.expandtab = true
|
||||
opt.shiftwidth = 4
|
||||
opt.tabstop = 4
|
||||
@@ -15,6 +16,7 @@ opt.smartindent = true
|
||||
opt.wrap = false
|
||||
opt.wildmode = "longest:full,full"
|
||||
opt.title = true
|
||||
opt.signcolumn = 'yes:1'
|
||||
|
||||
vim.cmd.colorscheme("slate")
|
||||
|
||||
|
||||
@@ -107,6 +107,53 @@ require("packer").startup(function(use)
|
||||
vim.g.pasta_disabled_filetypes = { "fugitive" }
|
||||
end,
|
||||
})
|
||||
-- Git integration.
|
||||
use({
|
||||
"lewis6991/gitsigns.nvim",
|
||||
config = function()
|
||||
require("gitsigns").setup({ current_line_blame = true })
|
||||
|
||||
vim.keymap.set("n", "]h", ":Gitsigns next_hunk<CR>")
|
||||
vim.keymap.set("n", "[h", ":Gitsigns prev_hunk<CR>")
|
||||
vim.keymap.set("n", "gs", ":Gitsigns stage_hunk<CR>")
|
||||
vim.keymap.set("n", "gS", ":Gitsigns undo_stage_hunk<CR>")
|
||||
vim.keymap.set("n", "gp", ":Gitsigns preview_hunk<CR>")
|
||||
vim.keymap.set("n", "gb", ":Gitsigns blame_line<CR>")
|
||||
end,
|
||||
})
|
||||
-- Git commands.
|
||||
use({
|
||||
"tpope/vim-fugitive",
|
||||
requires = "tpope/vim-rhubarb",
|
||||
config = function()
|
||||
require("tracer.plugins.fugitive").setup()
|
||||
end,
|
||||
})
|
||||
-- Improved syntax highlighting.
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
run = function()
|
||||
require("nvim-treesitter.install").update({ with_sync = true })
|
||||
end,
|
||||
requires = {
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
},
|
||||
config = function()
|
||||
pcall(require, "tracer.plugins.treesitter")
|
||||
end,
|
||||
})
|
||||
-- Language Server Protocol.
|
||||
use({
|
||||
"neovim/nvim-lspconfig",
|
||||
requires = {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
},
|
||||
config = function()
|
||||
pcall(require, "tracer.plugins.lspconfig")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Fuzzy finder
|
||||
use({
|
||||
@@ -119,7 +166,7 @@ require("packer").startup(function(use)
|
||||
},
|
||||
config = function()
|
||||
require("tracer.plugins.telescope")
|
||||
end,
|
||||
end,
|
||||
})
|
||||
|
||||
-- File tree sidebar for project-style navigation.
|
||||
|
||||
90
nvim/lua/tracer/plugins/fugitive.lua
Normal file
90
nvim/lua/tracer/plugins/fugitive.lua
Normal file
@@ -0,0 +1,90 @@
|
||||
local M = {}
|
||||
|
||||
local function homepage_for_remote(remote)
|
||||
local patterns = {
|
||||
"^gitea@([^:]+):(.+)%.git$",
|
||||
"^git@([^:]+):(.+)%.git$",
|
||||
"^ssh://git@([^/]+)/(.+)%.git$",
|
||||
"^https?://([^/]+)/(.+)%.git$",
|
||||
"^https?://([^/]+)/(.+)$",
|
||||
}
|
||||
|
||||
for _, pattern in ipairs(patterns) do
|
||||
local host, repo = remote:match(pattern)
|
||||
if host and repo then
|
||||
return ("https://%s/%s"):format(host, repo)
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
local function url_escape(value)
|
||||
return (value:gsub("#", "%%23"):gsub(" ", "%%20"))
|
||||
end
|
||||
|
||||
local function gitea_browse(opts)
|
||||
local root = homepage_for_remote(opts.remote or "")
|
||||
if not root then
|
||||
return nil
|
||||
end
|
||||
|
||||
local path = (opts.path or ""):gsub("^/", "")
|
||||
local ref = (opts.path or ""):match("^/?%.git/(refs/.*)")
|
||||
|
||||
if ref and ref:match("^refs/heads/") then
|
||||
local branch = ref:gsub("^refs/heads/", "")
|
||||
return root .. "/commits/branch/" .. url_escape(branch)
|
||||
end
|
||||
|
||||
if ref and ref:match("^refs/tags/") then
|
||||
local tag = ref:gsub("^refs/tags/", "")
|
||||
return root .. "/releases/tag/" .. url_escape(tag)
|
||||
end
|
||||
|
||||
if ref and ref:match("^refs/remotes/[^/]+/.+") then
|
||||
local branch = ref:match("^refs/remotes/[^/]+/(.+)$")
|
||||
return root .. "/commits/branch/" .. url_escape(branch)
|
||||
end
|
||||
|
||||
if (opts.path or ""):match("^/?%.git") then
|
||||
return root
|
||||
end
|
||||
|
||||
local commit = url_escape(opts.commit or "HEAD")
|
||||
local url
|
||||
|
||||
if opts.type == "tree" or path:match("/$") then
|
||||
url = root .. "/src/commit/" .. commit
|
||||
if path ~= "" then
|
||||
url = url .. "/" .. url_escape(path):gsub("/$", "")
|
||||
end
|
||||
elseif opts.type == "blob" or path:match("[^/]$") then
|
||||
url = root .. "/src/commit/" .. commit
|
||||
if path ~= "" then
|
||||
url = url .. "/" .. url_escape(path)
|
||||
end
|
||||
|
||||
if opts.line2 and opts.line1 and opts.line1 > 0 and opts.line1 == opts.line2 then
|
||||
url = url .. "#L" .. opts.line1
|
||||
elseif opts.line1 and opts.line2 and opts.line1 > 0 and opts.line2 > 0 then
|
||||
url = url .. "#L" .. opts.line1 .. "-L" .. opts.line2
|
||||
end
|
||||
else
|
||||
url = root .. "/commit/" .. commit
|
||||
end
|
||||
|
||||
return url
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
if vim.g.tracer_fugitive_gitea_handler_loaded then
|
||||
return
|
||||
end
|
||||
|
||||
vim.g.tracer_fugitive_gitea_handler_loaded = true
|
||||
vim.g.fugitive_browse_handlers = vim.g.fugitive_browse_handlers or {}
|
||||
table.insert(vim.g.fugitive_browse_handlers, 1, gitea_browse)
|
||||
end
|
||||
|
||||
return M
|
||||
34
nvim/lua/tracer/plugins/lspconfig.lua
Normal file
34
nvim/lua/tracer/plugins/lspconfig.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
-- Setup Mason to automatically install LSP servers
|
||||
require("mason").setup()
|
||||
|
||||
require("mason-lspconfig").setup({ automatic_installation = true })
|
||||
|
||||
-- Keymaps
|
||||
vim.keymap.set("n", "<Leader>d", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
|
||||
vim.keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>")
|
||||
vim.keymap.set("n", "gr", "<cmd>Telescope lsp_references<CR>")
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover)
|
||||
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename)
|
||||
|
||||
-- Emmet for HTML and JSX-style markup editing
|
||||
vim.lsp.config("emmet_language_server", {
|
||||
filetypes = {
|
||||
"css",
|
||||
"html",
|
||||
"javascriptreact",
|
||||
"less",
|
||||
"sass",
|
||||
"scss",
|
||||
"typescriptreact",
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.enable("intelephense")
|
||||
vim.lsp.enable("ts_ls")
|
||||
vim.lsp.enable("eslint")
|
||||
vim.lsp.enable("html")
|
||||
vim.lsp.enable("cssls")
|
||||
vim.lsp.enable("emmet_language_server")
|
||||
30
nvim/lua/tracer/plugins/treesitter.lua
Normal file
30
nvim/lua/tracer/plugins/treesitter.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
configs.setup({
|
||||
ensure_installed = "all",
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
["if"] = "@function.inner",
|
||||
["af"] = "@function.outer",
|
||||
["ia"] = "@parameter.inner",
|
||||
["aa"] = "@parameter.outer",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user