aboutsummaryrefslogtreecommitdiff
path: root/lua/user/lsp
diff options
context:
space:
mode:
authorAleksa Vuckovic <aleksa@vuckovic.cc>2023-02-24 03:54:38 +0100
committerAleksa Vuckovic <aleksa@vuckovic.cc>2023-02-24 03:54:38 +0100
commitbbe5d2d967a1a77328c71e11823bb57d56ee044c (patch)
tree1ad4f5ed0ecfd9bce0cc497a0be59ea9cad094fd /lua/user/lsp
parent0703660d49f22376d52a969e8c3cca64480b0f1b (diff)
formatting
Diffstat (limited to 'lua/user/lsp')
-rw-r--r--lua/user/lsp/ccls.lua72
-rw-r--r--lua/user/lsp/handlers.lua140
-rw-r--r--lua/user/lsp/init.lua2
-rw-r--r--lua/user/lsp/mason.lua32
4 files changed, 124 insertions, 122 deletions
diff --git a/lua/user/lsp/ccls.lua b/lua/user/lsp/ccls.lua
index 94fe2a0..b3393da 100644
--- a/lua/user/lsp/ccls.lua
+++ b/lua/user/lsp/ccls.lua
@@ -1,58 +1,58 @@
local status, lspconfig = pcall(require, "lspconfig")
if not status then
- return
+ return
end
vim.notify(vim.fn.expand('%:p'));
local extraArgs_opt = {};
-if string.match(vim.fn.expand('%:p'),"/home/aleksa/mygit/benet.rs/") then
- vim.opt["shiftwidth"]=2;
- vim.opt["tabstop"]=2;
- vim.opt["expandtab"]=true;
- vim.notify("jsx");
+if string.match(vim.fn.expand('%:p'), "/home/aleksa/mygit/benet.rs/") then
+ vim.opt["shiftwidth"] = 2;
+ vim.opt["tabstop"] = 2;
+ vim.opt["expandtab"] = true;
+ vim.notify("jsx");
end
-if string.match(vim.fn.expand('%:p'),"/home/aleksa/mygit/oldrepos/mykernel/") then
- extraArgs_opt = { "--sysroot=/opt/aleksa", "--gcc-toolchain=/opt/aleksa/usr/bin/i686-aleksa-gcc", };
- vim.notify("mykernel");
+if string.match(vim.fn.expand('%:p'), "/home/aleksa/mygit/oldrepos/mykernel/") then
+ extraArgs_opt = { "--sysroot=/opt/aleksa", "--gcc-toolchain=/opt/aleksa/usr/bin/i686-aleksa-gcc", };
+ vim.notify("mykernel");
end
-if string.match(vim.fn.expand('%:p'),"/media/linux/") then
- extraArgs_opt = { "--sysroot=/media/linux/staging/", };
- vim.notify("linux");
+if string.match(vim.fn.expand('%:p'), "/media/linux/") then
+ extraArgs_opt = { "--sysroot=/media/linux/staging/", };
+ vim.notify("linux");
end
-if string.match(vim.fn.expand('%:p'),"/home/aleksa/files/arduino_avr") then
- extraArgs_opt = { "--sysroot=/usr/avr", };
- vim.notify("arduino-avr");
+if string.match(vim.fn.expand('%:p'), "/home/aleksa/files/arduino_avr") then
+ extraArgs_opt = { "--sysroot=/usr/avr", };
+ vim.notify("arduino-avr");
end
-if string.match(vim.fn.expand('%:p'),"/home/aleksa/mygit/mykernel64") then
- extraArgs_opt = { "--sysroot=/home/aleksa/mygit/mykernel64/kernel", };
- vim.notify("mykernel64");
+if string.match(vim.fn.expand('%:p'), "/home/aleksa/mygit/mykernel64") then
+ extraArgs_opt = { "--sysroot=/home/aleksa/mygit/mykernel64/kernel", };
+ vim.notify("mykernel64");
end
lspconfig.ccls.setup {
- on_attach = require("user.lsp.handlers").on_attach,
- capabilities = require("user.lsp.handlers").capabilities,
-
- flags = {
- debounce_text_changes = 150,
- };
- init_options = {
- cache = {
- directory = "/tmp/ccls-cache";
- };
- index = {
- threads = 0;
- };
- clang = {
- excludeArgs = { "-frounding-math"};
- extraArgs = extraArgs_opt;
- }
- };
+ on_attach = require("user.lsp.handlers").on_attach,
+ capabilities = require("user.lsp.handlers").capabilities,
+
+ flags = {
+ debounce_text_changes = 150,
+ },
+ init_options = {
+ cache = {
+ directory = "/tmp/ccls-cache",
+ },
+ index = {
+ threads = 0,
+ },
+ clang = {
+ excludeArgs = { "-frounding-math" },
+ extraArgs = extraArgs_opt,
+ }
+ },
}
diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua
index b741928..ee802b9 100644
--- a/lua/user/lsp/handlers.lua
+++ b/lua/user/lsp/handlers.lua
@@ -1,101 +1,103 @@
local M = {}
M.setup = function()
- local signs = {
- { name = "DiagnosticSignError", text = "" },
- { name = "DiagnosticSignWarn", text = "" },
- { name = "DiagnosticSignHint", text = "" },
- { name = "DiagnosticSignInfo", text = "" },
- }
+ local signs = {
+ { name = "DiagnosticSignError", text = "" },
+ { name = "DiagnosticSignWarn", text = "" },
+ { name = "DiagnosticSignHint", text = "" },
+ { name = "DiagnosticSignInfo", text = "" },
+ }
- for _, sign in ipairs(signs) do
- vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
- end
+ for _, sign in ipairs(signs) do
+ vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
+ end
- local config = {
- -- disable virtual text
- virtual_text = true,
- -- show signs
- signs = {
- active = signs,
- },
- update_in_insert = true,
- underline = true,
- severity_sort = true,
- float = {
- focusable = false,
- style = "minimal",
- border = "rounded",
- source = "always",
- header = "",
- prefix = "",
- },
- }
+ local config = {
+ -- disable virtual text
+ virtual_text = true,
+ -- show signs
+ signs = {
+ active = signs,
+ },
+ update_in_insert = true,
+ underline = true,
+ severity_sort = true,
+ float = {
+ focusable = false,
+ style = "minimal",
+ border = "rounded",
+ source = "always",
+ header = "",
+ prefix = "",
+ },
+ }
- vim.diagnostic.config(config)
+ vim.diagnostic.config(config)
- vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
- border = "rounded",
- })
+ vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
+ border = "rounded",
+ })
- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
- border = "rounded",
- })
+ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
+ border = "rounded",
+ })
end
local function lsp_highlight_document(client)
- -- Set autocommands conditional on server_capabilities
- if client.server_capabilities.document_highlight then
- vim.api.nvim_exec(
- [[
+ -- Set autocommands conditional on server_capabilities
+ if client.server_capabilities.document_highlight then
+ vim.api.nvim_exec(
+ [[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]],
- false
- )
- end
+ false
+ )
+ end
end
local function lsp_keymaps(bufnr)
- local opts = { noremap = true, silent = true }
- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
- -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
- -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
- -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
- vim.api.nvim_buf_set_keymap(
- bufnr,
- "n",
- "gl",
- '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ border = "rounded" })<CR>',
- opts
- )
- vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
- vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
+ local opts = { noremap = true, silent = true }
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>',
+ opts)
+ vim.api.nvim_buf_set_keymap(
+ bufnr,
+ "n",
+ "gl",
+ '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ border = "rounded" })<CR>',
+ opts
+ )
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>',
+ opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
+ vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
end
M.on_attach = function(client, bufnr)
- if client.name == "tsserver" then
- client.server_capabilities.document_formatting = false
- end
- lsp_keymaps(bufnr)
- lsp_highlight_document(client)
+ if client.name == "tsserver" then
+ client.server_capabilities.document_formatting = false
+ end
+ lsp_keymaps(bufnr)
+ lsp_highlight_document(client)
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not status_ok then
- return
+ return
end
M.capabilities = cmp_nvim_lsp.default_capabilities(capabilities)
diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua
index 202cccb..4ac9a3e 100644
--- a/lua/user/lsp/init.lua
+++ b/lua/user/lsp/init.lua
@@ -2,7 +2,7 @@ require "user.lsp.mason"
local status, lspconfig = pcall(require, "lspconfig")
if not status then
- return
+ return
end
require "user.lsp.ccls"
diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua
index 1b5717d..2c14313 100644
--- a/lua/user/lsp/mason.lua
+++ b/lua/user/lsp/mason.lua
@@ -1,43 +1,43 @@
local status, mason = pcall(require, "mason")
if not status then
- return
+ return
end
-- mason
mason.setup({
- ui = {
- icons = {
- package_installed = "✓",
- package_pending = "➜",
- package_uninstalled = "✗"
- }
- }
+ ui = {
+ icons = {
+ package_installed = "✓",
+ package_pending = "➜",
+ package_uninstalled = "✗"
+ }
+ }
})
-- mason-lspconfig
require("mason-lspconfig").setup {
- ensure_installed = { "pylsp", "bashls", "lua_ls", "cmake" },
+ ensure_installed = { "pylsp", "bashls", "lua_ls", "cmake" },
}
require("mason-lspconfig").setup_handlers {
- function (server_name)
+ function(server_name)
require("lspconfig")[server_name].setup {}
end
}
-- mason-null-ls
require('mason-null-ls').setup({
- automatic_setup = true,
- ensure_installed = { "cpplint" }
+ automatic_setup = true,
+ ensure_installed = {}
})
require('mason-null-ls').setup_handlers {
- function(source_name, methods)
- require("mason-null-ls.automatic_setup")(source_name, methods)
- end,
+ function(source_name, methods)
+ require("mason-null-ls.automatic_setup")(source_name, methods)
+ end,
}
-- null_ls
local status, null_ls = pcall(require, "null-ls")
if not status then
- return
+ return
end
null_ls.setup()