diff options
Diffstat (limited to 'modules/tools/editor/neovim/plugins/config')
7 files changed, 114 insertions, 0 deletions
diff --git a/modules/tools/editor/neovim/plugins/config/base16.mustache.lua b/modules/tools/editor/neovim/plugins/config/base16.mustache.lua new file mode 100644 index 0000000..3c13fcc --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/base16.mustache.lua @@ -0,0 +1,12 @@ +vim.o.termguicolors = true; +vim.opt.termguicolors = true; +vim.o.background = "dark"; +vim.g.base16colorspace = 256 +vim.cmd.colorscheme("base16-scheme"); + +-- Overrides +-- disable the background of line numbers +vim.api.nvim_set_hl(0, "LineNr", { link = "Normal" }); + +-- change the color of the pane separator +vim.api.nvim_set_hl(0, "WinSeparator", { fg = "#{{base02-hex}}", bg = "None" }); diff --git a/modules/tools/editor/neovim/plugins/config/comment.lua b/modules/tools/editor/neovim/plugins/config/comment.lua new file mode 100644 index 0000000..9086261 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/comment.lua @@ -0,0 +1 @@ +require("Comment").setup(); diff --git a/modules/tools/editor/neovim/plugins/config/default.nix b/modules/tools/editor/neovim/plugins/config/default.nix new file mode 100644 index 0000000..fb2ac1a --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/default.nix @@ -0,0 +1,19 @@ +{ config }: + +let + extra = if config.tools.editor.neovim.configuration == "full" then +'' +${builtins.readFile ./lsp-config.lua} +'' + else ""; +in +'' +${builtins.readFile ./comment.lua} +${builtins.readFile ./lualine.lua} +${import ./treesitter.nix { inherit config; }} +${builtins.readFile (config.scheme { + template = builtins.readFile ./base16.mustache.lua; +})} +${builtins.readFile ./nvim-tree.lua} +${extra} +'' diff --git a/modules/tools/editor/neovim/plugins/config/lsp-config.lua b/modules/tools/editor/neovim/plugins/config/lsp-config.lua new file mode 100644 index 0000000..43cdb95 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/lsp-config.lua @@ -0,0 +1,51 @@ +local lspconfig = require("lspconfig"); + +local filetype_to_lsp = { + lua = "lua_ls", + cpp = "clangd", + c = "clangd", + python = "pyright", + javascript = "tsserver", + typescript = "tsserver", + go = "gopls", + html = "html", + css = "cssls", + json = "jsonls", + bash = "bashls", + graphql = "graphql", + dockerfile = "dockerls", + php = "phpactor", + rust = "rust_analyzer", + haskell = "hls", + deno = "denols", + vim = "vimls", + elixir = "elixirls", + clojure = "clojure_lsp", + scala = "scala_metals", + ruby = "sorbet", +}; + +-- Keeping track of all the lsps that have been already configured +local lsp_setup_done = {}; + +-- Function to setup LSP based on filetype +local function setup_lsp(filetype) + local lsp_server = filetype_to_lsp[filetype]; + if lsp_server and not lsp_setup_done[lsp_server] then + lsp_setup_done[lsp_server] = true; + lspconfig[lsp_server].setup({}); + end +end + +vim.keymap.set("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true }); +vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { noremap = true, silent = true }); +vim.keymap.set("n", "gr", vim.lsp.buf.references, { noremap = true, silent = true }); +vim.keymap.set("i", "<C-c>", vim.lsp.buf.completion, { noremap = true, silent = true }); +vim.keymap.set("n", "gk", vim.lsp.buf.hover, { noremap = true, silent = true }); + +vim.api.nvim_create_autocmd("FileType", { + pattern = "*", -- Match all file types + callback = function() + setup_lsp(vim.bo.filetype); -- Call the setup_lsp function only if the filetype is in the mapping + end, +}); diff --git a/modules/tools/editor/neovim/plugins/config/lualine.lua b/modules/tools/editor/neovim/plugins/config/lualine.lua new file mode 100644 index 0000000..ba2eda6 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/lualine.lua @@ -0,0 +1,5 @@ +require("lualine").setup { + options = { + globalstatus = true, + }, +}; diff --git a/modules/tools/editor/neovim/plugins/config/nvim-tree.lua b/modules/tools/editor/neovim/plugins/config/nvim-tree.lua new file mode 100644 index 0000000..c6c4102 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/nvim-tree.lua @@ -0,0 +1,13 @@ +require("nvim-tree").setup { + filters = { + enable = false + }, + renderer = { + indent_markers = { + enable = true + }, + root_folder_label = function(path) + return vim.fn.fnamemodify(path, ":t") + end, + }, +}; diff --git a/modules/tools/editor/neovim/plugins/config/treesitter.nix b/modules/tools/editor/neovim/plugins/config/treesitter.nix new file mode 100644 index 0000000..be0bdb6 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/treesitter.nix @@ -0,0 +1,13 @@ +{ config }: + +'' +require("nvim-treesitter.configs").setup { + auto_install = true, + highlight = { + enable = true, + }, + parser_install_dir = "${config.xdg.dataHome}/nvim", +}; + +vim.opt.runtimepath:append("${config.xdg.dataHome}/nvim"); +'' |
