summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-08-04 09:05:04 +0200
committerhozan23 <hozan23@karyontech.net>2024-08-04 09:05:04 +0200
commit5e774de1f40616cd4fec2f600a5f2b99612e028b (patch)
tree0ab344a4ea34416a45e7cb33b26a3a11e013495d /plugin
init commitHEADmaster
Diffstat (limited to 'plugin')
-rw-r--r--plugin/git.lua4
-rw-r--r--plugin/lsp.lua121
-rw-r--r--plugin/theme.lua19
3 files changed, 144 insertions, 0 deletions
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" }, "<C-i>",
+ "<cmd>lua vim.lsp.buf.format({async = true})<cr>",
+ 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
+ ["<CR>"] = cmp.mapping.confirm({ select = false }),
+
+ -- Ctrl + space triggers completion menu
+ ["<C-Space>"] = 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"