summaryrefslogtreecommitdiff
path: root/lua/config
diff options
context:
space:
mode:
Diffstat (limited to 'lua/config')
-rw-r--r--lua/config/lsp.lua82
-rw-r--r--lua/config/plugins/completion.lua29
-rw-r--r--lua/config/plugins/lsp.lua106
3 files changed, 82 insertions, 135 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
new file mode 100644
index 0000000..ebb779f
--- /dev/null
+++ b/lua/config/lsp.lua
@@ -0,0 +1,82 @@
+vim.o.completeopt = "menuone,noselect,noinsert,popup,fuzzy"
+
+vim.diagnostic.config({
+ underline = true,
+ virtual_lines = { current_line = true },
+ signs = {
+ text = {
+ [vim.diagnostic.severity.ERROR] = "",
+ [vim.diagnostic.severity.WARN] = "",
+ [vim.diagnostic.severity.INFO] = "",
+ [vim.diagnostic.severity.HINT] = "",
+ },
+ },
+})
+
+vim.lsp.config("*", {
+ capabilities = {
+ textDocument = {
+ semanticTokens = {
+ multilineTokenSupport = true,
+ },
+ completion = {
+ completionItem = {
+ snippetSupport = true,
+ commitCharactersSupport = true,
+ deprecatedSupport = true,
+ preselectSupport = true,
+ insertReplaceSupport = true,
+ labelDetailsSupport = true,
+ resolveSupport = {
+ properties = {
+ "documentation",
+ "detail",
+ "additionalTextEdits",
+ },
+ },
+ },
+ },
+ },
+ },
+
+ on_attach = function(client, bufnr)
+ if client:supports_method('textDocument/completion') then
+ vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true })
+ vim.keymap.set("i", "<M-Space>", vim.lsp.completion.get, { buffer = bufnr })
+ end
+
+ if client:supports_method('textDocument/definition') then
+ vim.keymap.set("n", "grd", vim.lsp.buf.definition, { desc = "Jumps to definition", buffer = bufnr })
+ end
+ if client:supports_method('textDocument/declaration') then
+ vim.keymap.set("n", "grD", vim.lsp.buf.declaration, { desc = "Jumps to declaration", buffer = bufnr })
+ end
+
+ if client:supports_method("textDocument/inlayHint") then
+ vim.lsp.inlay_hint.enable(true, { bufnr })
+ end
+
+ if client:supports_method("textDocument/formatting") then
+ local description = "LSP: Formats the current buffer"
+ local format_buffer = function()
+ vim.lsp.buf.format({ async = true, buffer = bufnr })
+ end
+ vim.keymap.set("n", "<Leader>cf", format_buffer, { desc = description })
+ vim.keymap.set("v", "<C-f>", format_buffer, { desc = description })
+ end
+ end,
+})
+
+vim.lsp.enable({
+ "clangd",
+ "css",
+ "go",
+ "html",
+ "javascript",
+ "json",
+ "lua",
+ "markdown",
+ "odin",
+ "ruby",
+ "yaml",
+})
diff --git a/lua/config/plugins/completion.lua b/lua/config/plugins/completion.lua
deleted file mode 100644
index f8cc602..0000000
--- a/lua/config/plugins/completion.lua
+++ /dev/null
@@ -1,29 +0,0 @@
-return {
- {
- "saghen/blink.cmp",
- dependencies = "rafamadriz/friendly-snippets",
-
- version = "v0.13.1",
-
- opts = {
- keymap = {
- preset = "default",
- -- The default `<C-Space>` is my tmux prefix.
- ["<M-Space>"] = { "show", "show_documentation", "hide_documentation" },
- },
-
- appearance = {
- use_nvim_cmp_as_default = true,
- nerd_font_variant = 'mono'
- },
-
- sources = {
- min_keyword_length = 2,
- default = { "lsp", "path", "snippets", "buffer" },
- },
-
- signature = { enabled = true },
- },
- opts_extend = { "sources.default" }
- }
-}
diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua
deleted file mode 100644
index 16e785d..0000000
--- a/lua/config/plugins/lsp.lua
+++ /dev/null
@@ -1,106 +0,0 @@
-return {
- {
- "neovim/nvim-lspconfig",
- dependencies = {
- "saghen/blink.cmp",
- },
- opts = {
- servers = {
- clangd = {
- cmd = {
- "clangd",
- "--header-insertion=iwyu",
- "--background-index",
- "--clang-tidy",
- "--log=verbose",
- },
- filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
- single_file_support = true,
- },
- cssls = {},
- html = {},
- jsonls = {},
- lua_ls = {
- settings = {
- Lua = {
- runtime = {
- version = "LuaJIT",
- },
- diagnostics = {
- globals = {
- "vim",
- "require",
- },
- },
- workspace = {
- library = vim.api.nvim_get_runtime_file("", true),
- },
- telemetry = {
- enable = false,
- },
- },
- },
- },
- marksman = {},
- solargraph = {
- cmd = {
- vim.fn.expand('~/.local/share/nvim/mason/bin/solargraph'),
- 'stdio',
- },
- },
- ts_ls = {},
- },
- },
-
- config = function(_, opts)
- local lspconfig = require("lspconfig")
- local blink = require("blink.cmp")
-
- for server, config in pairs(opts.servers) do
- config.capabilities = blink.get_lsp_capabilities()
- lspconfig[server].setup(config)
- end
-
- vim.api.nvim_create_autocmd("LspAttach", {
- callback = function(args)
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- if not client then return end
-
- vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Jumps to definition", buffer = args.buf })
- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Jumps to declaration", buffer = args.buf })
- vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Lists all implementations", buffer = args.buf })
-
- vim.keymap.set("n", "<Leader>cf", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end,
- { desc = "Formats a buffer", buffer = args.buf })
- vim.keymap.set("v", "<C-f>", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end,
- { desc = "Formats a buffer", buffer = args.buf })
-
- -- Disabled, kept temporarily here just for reference
- if false and vim.bo.filetype == "lua" then
- if client.supports_method("textDocument/formatting") then
- vim.api.nvim_create_autocmd("BufWritePre", {
- buffer = args.buf,
- callback = function()
- vim.lsp.buf.format({ bufnr = args.buf, id = client.id })
- end,
- })
- end
- end
- end
- })
-
- vim.diagnostic.config({
- underline = true,
- virtual_text = { prefix = " ●", },
- signs = {
- text = {
- [vim.diagnostic.severity.ERROR] = "",
- [vim.diagnostic.severity.WARN] = "",
- [vim.diagnostic.severity.INFO] = "",
- [vim.diagnostic.severity.HINT] = "",
- },
- },
- })
- end,
- },
-}