LSP
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
local function set_gitsigns_blame_highlight()
|
||||
vim.api.nvim_set_hl(0, "GitSignsCurrentLineBlame", {
|
||||
fg = "#f0a97e",
|
||||
italic = true,
|
||||
})
|
||||
end
|
||||
|
||||
local highlight_group = vim.api.nvim_create_augroup("tracer_highlights", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
group = highlight_group,
|
||||
callback = set_gitsigns_blame_highlight,
|
||||
})
|
||||
|
||||
set_gitsigns_blame_highlight()
|
||||
@@ -15,6 +15,7 @@ opt.softtabstop = 4
|
||||
opt.smartindent = true
|
||||
opt.wrap = false
|
||||
opt.wildmode = "longest:full,full"
|
||||
opt.completeopt = "menuone,longest,preview"
|
||||
opt.title = true
|
||||
opt.signcolumn = 'yes:1'
|
||||
|
||||
|
||||
@@ -182,12 +182,30 @@ require("packer").startup(function(use)
|
||||
requires = {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"b0o/schemastore.nvim",
|
||||
},
|
||||
config = function()
|
||||
pcall(require, "tracer.plugins.lspconfig")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Completion
|
||||
use({
|
||||
"hrsh7th/nvim-cmp",
|
||||
requires = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-nvim-lsp-signature-help",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"onsails/lspkind.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("tracer.plugins.cmp")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Fuzzy finder
|
||||
use({
|
||||
"nvim-telescope/telescope.nvim",
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
local lspkind = require("lspkind")
|
||||
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
formatting = {
|
||||
format = lspkind.cmp_format(),
|
||||
},
|
||||
mapping = {
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
},
|
||||
sources = {
|
||||
{
|
||||
name = "nvim_lsp",
|
||||
option = {
|
||||
php = {
|
||||
keyword_pattern = [=[[\%(\$\k*\)\|\k\+]]=],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ name = "nvim_lsp_signature_help" },
|
||||
{ name = "luasnip" },
|
||||
{
|
||||
name = "buffer",
|
||||
option = {
|
||||
keyword_pattern = [=[[\%(\$\k*\)\|\k\+]]=],
|
||||
},
|
||||
},
|
||||
{ name = "path" },
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
})
|
||||
@@ -3,6 +3,12 @@ require("mason").setup()
|
||||
|
||||
require("mason-lspconfig").setup({ automatic_installation = true })
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
vim.lsp.config("*", {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
-- Keymaps
|
||||
vim.keymap.set("n", "<Leader>d", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
|
||||
@@ -13,6 +19,20 @@ 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)
|
||||
|
||||
-- Sign configuration
|
||||
vim.fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" })
|
||||
vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" })
|
||||
vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" })
|
||||
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Emmet for HTML and JSX-style markup editing
|
||||
vim.lsp.config("emmet_language_server", {
|
||||
filetypes = {
|
||||
@@ -26,9 +46,18 @@ vim.lsp.config("emmet_language_server", {
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.config("jsonls", {
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.enable("intelephense")
|
||||
vim.lsp.enable("ts_ls")
|
||||
vim.lsp.enable("eslint")
|
||||
vim.lsp.enable("html")
|
||||
vim.lsp.enable("cssls")
|
||||
vim.lsp.enable("jsonls")
|
||||
vim.lsp.enable("emmet_language_server")
|
||||
|
||||
Reference in New Issue
Block a user