summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--init.lua29
-rw-r--r--lua/plugins.lua33
-rw-r--r--plugin/git.lua4
-rw-r--r--plugin/lsp.lua121
-rw-r--r--plugin/theme.lua19
6 files changed, 207 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c84aa4a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+plugin/packer_compiled.lua
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..cb7eb79
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,29 @@
+require('plugins')
+
+--------------------------
+-- General configs
+--------------------------
+vim.g.mapleader = " "
+
+vim.opt.guicursor = ""
+
+vim.opt.nu = true
+vim.opt.relativenumber = true
+
+vim.opt.smartindent = true
+
+vim.opt.hlsearch = true
+vim.opt.incsearch = true
+
+vim.opt.colorcolumn = "80"
+vim.opt.signcolumn = "auto:1"
+
+vim.opt.tabstop = 4
+vim.opt.softtabstop = 4
+vim.opt.shiftwidth = 4
+vim.opt.expandtab = true
+
+--------------------------
+-- Keymap
+--------------------------
+vim.keymap.set("n", "<C-n>", vim.cmd.noh)
diff --git a/lua/plugins.lua b/lua/plugins.lua
new file mode 100644
index 0000000..6d0857f
--- /dev/null
+++ b/lua/plugins.lua
@@ -0,0 +1,33 @@
+-- This file can be loaded by calling `lua require('plugins')` from your
+-- init.vim
+
+-- Only required if you have packer configured as `opt`
+vim.cmd([[packadd packer.nvim]])
+
+return require("packer").startup(function(use)
+ -- Packer can manage itself
+ use("wbthomason/packer.nvim")
+
+ -- Lsp config plugin
+ use({ "neovim/nvim-lspconfig" })
+
+ -- Manage lsp servers, linters, and formatters
+ use({ "williamboman/mason.nvim" })
+ use({ "williamboman/mason-lspconfig.nvim" })
+
+ -- Auto completion
+ use({ "hrsh7th/nvim-cmp" })
+ use({ "hrsh7th/cmp-nvim-lsp" })
+
+ -- Gruvbox theme
+ use({ "ellisonleao/gruvbox.nvim" })
+
+ -- Vim airline plugin
+ use({ "vim-airline/vim-airline" })
+ use({ "vim-airline/vim-airline-themes" })
+
+ -- Git plugins
+ use({ "tpope/vim-fugitive" })
+ use({ "tpope/vim-rhubarb" })
+ use({ "shumphrey/fugitive-gitlab.vim" })
+end)
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"