From 5e774de1f40616cd4fec2f600a5f2b99612e028b Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sun, 4 Aug 2024 09:05:04 +0200 Subject: init commit --- plugin/git.lua | 4 ++ plugin/lsp.lua | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugin/theme.lua | 19 +++++++++ 3 files changed, 144 insertions(+) create mode 100644 plugin/git.lua create mode 100644 plugin/lsp.lua create mode 100644 plugin/theme.lua (limited to 'plugin') diff --git a/plugin/git.lua b/plugin/git.lua new file mode 100644 index 0000000..4170e5d --- /dev/null +++ b/plugin/git.lua @@ -0,0 +1,4 @@ +-------------------------- +-- Gitlab domains +-------------------------- +vim.g.fugitive_gitlab_domains = {"https://gitlab.torproject.org"} diff --git a/plugin/lsp.lua b/plugin/lsp.lua new file mode 100644 index 0000000..90f1877 --- /dev/null +++ b/plugin/lsp.lua @@ -0,0 +1,121 @@ +local lspconfig = require("lspconfig") + +-------------------------- +-- LSP keybindings +-------------------------- +vim.api.nvim_create_autocmd("LspAttach", { + desc = "LSP actions", + callback = function(event) + local opts = { buffer = event.buf } + vim.keymap.set("n", "K", function() + vim.lsp.buf.hover() + end, opts) + + vim.keymap.set("n", "]e", function() + vim.diagnostic.goto_next() + end, opts) + + vim.keymap.set("n", "[e", function() + vim.diagnostic.goto_prev() + end, opts) + + vim.keymap.set({ "n", "x" }, "", + "lua vim.lsp.buf.format({async = true})", + opts) + end, +}) + +-------------------------- +-- Auto completion setup +-------------------------- +local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() +local default_setup = function(server) + lspconfig[server].setup({ capabilities = lsp_capabilities }) +end + +local cmp = require("cmp") +cmp.setup({ + sources = { + { name = "nvim_lsp" }, + }, + mapping = cmp.mapping.preset.insert({ + -- Enter key confirms completion item + [""] = cmp.mapping.confirm({ select = false }), + + -- Ctrl + space triggers completion menu + [""] = cmp.mapping.complete(), + }), + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = { + winhighlight = "Normal:CmpNormal", + }, + documentation = { + winhighlight = "Normal:CmpDocNormal", + }, + }, +}) + +-------------------------- +-- Setup mason +-------------------------- +require("mason").setup({}) +require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + "rust_analyzer", + "gopls", + "ruff_lsp", + "tsserver", + "clangd", + "taplo", + "bashls", + "yamlls", + "dockerls", + "texlab", + "cssls", + "html", + }, + handlers = { + default_setup, + }, +}) + +-- Disable the annoying warning "undefined vim" +lspconfig.lua_ls.setup({ + capabilities = lsp_capabilities, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + }, + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + vim.env.VIMRUNTIME, + }, + }, + }, + }, +}) + +-- rust_analyzer setup +lspconfig.rust_analyzer.setup({ + -- Server-specific settings. See `:help lspconfig-setup` + -- settings = { + -- ["rust-analyzer"] = { + -- cargo = { + -- allFeatures = true, + -- }, + -- }, + -- }, +}) + +-- dartls setup +lspconfig.dartls.setup({}) diff --git a/plugin/theme.lua b/plugin/theme.lua new file mode 100644 index 0000000..9db4940 --- /dev/null +++ b/plugin/theme.lua @@ -0,0 +1,19 @@ +-------------------------- +-- Gruvbox Theme +-------------------------- +require("gruvbox").setup({ + palette_overrides = { + dark0 = "#181818", + dark1 = "#202020", + dark2 = "#282828", + dark3 = "#383838", + dark4 = "#484848", + } +}) +vim.o.background = "dark" -- or "light" for light mode +vim.cmd([[colorscheme gruvbox]]) + +-------------------------- +-- Airline theme +-------------------------- +vim.g.airline_theme = "base16_black_metal_mayhem" -- cgit v1.2.3