From d97c6f1c2c957c061f65238d5308b17b861610cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20K=C3=A4nner?= Date: Thu, 23 Feb 2023 23:25:59 +0100 Subject: [PATCH] Initial config --- lsp/on_attach.lua | 9 +++++++++ lsp/server-settings/clangd.lua | 5 +++++ lsp/server-settings/rust_analyzer.lua | 15 +++++++++++++++ options.lua | 26 ++++++++++++++++++++++++++ plugins/init.lua | 19 +++++++++++++++++++ plugins/lsp-inlayhints.lua | 1 + updater.lua | 12 ++++++++++++ 7 files changed, 87 insertions(+) create mode 100644 lsp/on_attach.lua create mode 100644 lsp/server-settings/clangd.lua create mode 100644 lsp/server-settings/rust_analyzer.lua create mode 100644 options.lua create mode 100644 plugins/init.lua create mode 100644 plugins/lsp-inlayhints.lua create mode 100644 updater.lua diff --git a/lsp/on_attach.lua b/lsp/on_attach.lua new file mode 100644 index 0000000..bb471c5 --- /dev/null +++ b/lsp/on_attach.lua @@ -0,0 +1,9 @@ +return function(client, bufnr) + if client.server_capabilities.inlayHintProvider then + local inlayhints_avail, inlayhints = pcall(require, "lsp-inlayhints") + if inlayhints_avail then + inlayhints.on_attach(client, bufnr) + vim.keymap.set("n", "uH", function() inlayhints.toggle() end, { desc = "Toggle inlay hints" }) + end + end +end diff --git a/lsp/server-settings/clangd.lua b/lsp/server-settings/clangd.lua new file mode 100644 index 0000000..d3ae464 --- /dev/null +++ b/lsp/server-settings/clangd.lua @@ -0,0 +1,5 @@ +return { + capabilities = { + offsetEncoding = "utf-8", + }, +} diff --git a/lsp/server-settings/rust_analyzer.lua b/lsp/server-settings/rust_analyzer.lua new file mode 100644 index 0000000..e430d66 --- /dev/null +++ b/lsp/server-settings/rust_analyzer.lua @@ -0,0 +1,15 @@ +return { + settings = { + ["rust-analyzer"] = { + checkOnSave = { + command = "clippy", + extraArgs = { + "--all-features", + "--", + "-W", "clippy::pedantic", + "-W", "clippy::nursery", + }, + }, + }, + }, +} diff --git a/options.lua b/options.lua new file mode 100644 index 0000000..4bac5b3 --- /dev/null +++ b/options.lua @@ -0,0 +1,26 @@ +return { + opt = { + relativenumber = true, + number = true, + spell = true, + signcolumn = "auto", + wrap = true, + conceallevel = 2, + foldenable = false, + foldexpr = "nvim_treesitter#foldexpr()", + foldmethod = "expr", + linebreak = true, + list = true, + listchars = { tab = " ", extends = "⟩", precedes = "⟨", trail = "·", eol = "󱞥" }, + showbreak = "󱞪 ", + }, + g = { + mapleader = " ", + autoformat_enabled = true, + cmp_enabled = true, + autopairs_enabled = true, + diagnostics_enabled = true, + status_diagnostics_enabled = true, + icons_enabled = true, + } +} diff --git a/plugins/init.lua b/plugins/init.lua new file mode 100644 index 0000000..8e0b7d8 --- /dev/null +++ b/plugins/init.lua @@ -0,0 +1,19 @@ +return { + ["simrat39/rust-tools.nvim"] = { + after = {"mason-lspconfig.nvim"}, + config = function() + require("rust-tools").setup({ + tools = { + inlay_hints = { + auto = false + } + }, + server = astronvim.lsp.server_settings "rust_analyzer", + }) + end, + }, + ["lvimuser/lsp-inlayhints.nvim"] = { + module = "lsp-inlayhints", + config = function() require "user.plugins.lsp-inlayhints" end, + }, +} diff --git a/plugins/lsp-inlayhints.lua b/plugins/lsp-inlayhints.lua new file mode 100644 index 0000000..3c35054 --- /dev/null +++ b/plugins/lsp-inlayhints.lua @@ -0,0 +1 @@ +require("lsp-inlayhints").setup() diff --git a/updater.lua b/updater.lua new file mode 100644 index 0000000..e714f09 --- /dev/null +++ b/updater.lua @@ -0,0 +1,12 @@ +return { + remote = "origin", + channel = "stable", + version = "latest", + branch = "main", + commit = nil, + pin_plugins = nil, + skip_prompts = false, + show_changelog = true, + auto_reload = true, + auto_quit = true, +}