From 98750e1a51012c18478f1888dac370339fadbf1f Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sat, 25 Jun 2022 16:00:14 +0200 Subject: [PATCH] refactor(nvim): clean up lua file structure --- home-mandlm.nix | 55 +++++++---------------- nvim/comment.lua | 1 + nvim/gitsigns.lua | 1 + nvim/indent-blankline.lua | 6 +++ nvim/init.lua | 4 -- nvim/{lua => }/keymaps.lua | 0 nvim/{lua/plugins => }/lspconfig.lua | 0 nvim/lua/plugins.lua | 39 ---------------- nvim/lua/plugins/bufferline.lua | 19 -------- nvim/lua/plugins/nvim-lsp-setup.lua | 65 --------------------------- nvim/lualine.lua | 7 +++ nvim/luasnip.lua | 1 + nvim/notify.lua | 2 + nvim/{lua/plugins => }/nvim-cmp.lua | 0 nvim/{lua => }/options.lua | 0 nvim/tabline.lua | 1 + nvim/{lua/plugins => }/telescope.lua | 0 nvim/{lua => }/themes.lua | 2 +- nvim/toggleterm.lua | 1 + nvim/{lua/plugins => }/treesitter.lua | 0 20 files changed, 37 insertions(+), 167 deletions(-) create mode 100644 nvim/comment.lua create mode 100644 nvim/gitsigns.lua create mode 100644 nvim/indent-blankline.lua delete mode 100644 nvim/init.lua rename nvim/{lua => }/keymaps.lua (100%) rename nvim/{lua/plugins => }/lspconfig.lua (100%) delete mode 100644 nvim/lua/plugins.lua delete mode 100644 nvim/lua/plugins/bufferline.lua delete mode 100644 nvim/lua/plugins/nvim-lsp-setup.lua create mode 100644 nvim/lualine.lua create mode 100644 nvim/luasnip.lua create mode 100644 nvim/notify.lua rename nvim/{lua/plugins => }/nvim-cmp.lua (100%) rename nvim/{lua => }/options.lua (100%) create mode 100644 nvim/tabline.lua rename nvim/{lua/plugins => }/telescope.lua (100%) rename nvim/{lua => }/themes.lua (53%) create mode 100644 nvim/toggleterm.lua rename nvim/{lua/plugins => }/treesitter.lua (100%) diff --git a/home-mandlm.nix b/home-mandlm.nix index 76f72c2..6a14eb0 100644 --- a/home-mandlm.nix +++ b/home-mandlm.nix @@ -88,7 +88,7 @@ kitty = { enable = true; - theme = "Solarized Dark"; + theme = "Solarized Light"; font = { name = "DejaVu Sans Mono"; size = 12; @@ -153,44 +153,21 @@ extraConfig = '' lua << EOF - ${builtins.readFile ./nvim/lua/keymaps.lua } - ${builtins.readFile ./nvim/lua/options.lua } - ${builtins.readFile ./nvim/lua/plugins/treesitter.lua } - - ${builtins.readFile ./nvim/lua/plugins/lspconfig.lua } - - require("toggleterm").setup({ size = 32, open_mapping = [[]] }) - - require("notify").setup({ stages = "fade" }) - vim.notify = require("notify") - - require('Comment').setup({}) - - require('lualine').setup({ - options = { globalstatus = true }, - sections = { - lualine_c = { { "filename", path = 1 }, "require('lsp-status').status()" } - }, - extensions = { "toggleterm" } - }) - - require('tabline').setup({ enable = true, options = { show_bufnr = true, show_filename_only = true }}) - - require("indent_blankline").setup { - char = "┊", - buftype_exclude = { "terminal", "help", "nofile" }, - filetype_exclude = { 'help', 'packer' }, - show_trailing_blankline_indent = false - } - - require('gitsigns').setup() - - require("luasnip.loaders.from_vscode").lazy_load() - - ${builtins.readFile ./nvim/lua/plugins/nvim-cmp.lua } - ${builtins.readFile ./nvim/lua/plugins/telescope.lua } - - ${builtins.readFile ./nvim/lua/themes.lua } + ${builtins.readFile ./nvim/keymaps.lua } + ${builtins.readFile ./nvim/options.lua } + ${builtins.readFile ./nvim/treesitter.lua } + ${builtins.readFile ./nvim/lspconfig.lua } + ${builtins.readFile ./nvim/toggleterm.lua } + ${builtins.readFile ./nvim/notify.lua } + ${builtins.readFile ./nvim/comment.lua } + ${builtins.readFile ./nvim/lualine.lua } + ${builtins.readFile ./nvim/tabline.lua } + ${builtins.readFile ./nvim/indent-blankline.lua } + ${builtins.readFile ./nvim/gitsigns.lua } + ${builtins.readFile ./nvim/luasnip.lua } + ${builtins.readFile ./nvim/nvim-cmp.lua } + ${builtins.readFile ./nvim/telescope.lua } + ${builtins.readFile ./nvim/themes.lua } EOF ''; }; diff --git a/nvim/comment.lua b/nvim/comment.lua new file mode 100644 index 0000000..5060319 --- /dev/null +++ b/nvim/comment.lua @@ -0,0 +1 @@ +require('Comment').setup({}) diff --git a/nvim/gitsigns.lua b/nvim/gitsigns.lua new file mode 100644 index 0000000..91fa65b --- /dev/null +++ b/nvim/gitsigns.lua @@ -0,0 +1 @@ +require('gitsigns').setup() diff --git a/nvim/indent-blankline.lua b/nvim/indent-blankline.lua new file mode 100644 index 0000000..921a59b --- /dev/null +++ b/nvim/indent-blankline.lua @@ -0,0 +1,6 @@ +require("indent_blankline").setup { + char = "┊", + buftype_exclude = { "terminal", "help", "nofile" }, + filetype_exclude = { 'help', 'packer' }, + show_trailing_blankline_indent = false +} diff --git a/nvim/init.lua b/nvim/init.lua deleted file mode 100644 index 49b81ae..0000000 --- a/nvim/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -require("keymaps") -require('options') -require('plugins') -require('themes') diff --git a/nvim/lua/keymaps.lua b/nvim/keymaps.lua similarity index 100% rename from nvim/lua/keymaps.lua rename to nvim/keymaps.lua diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lspconfig.lua similarity index 100% rename from nvim/lua/plugins/lspconfig.lua rename to nvim/lspconfig.lua diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua deleted file mode 100644 index f180b1b..0000000 --- a/nvim/lua/plugins.lua +++ /dev/null @@ -1,39 +0,0 @@ -return require('packer').startup(function(use) - -- language server - use { - 'junnplus/nvim-lsp-setup', - requires = { - 'neovim/nvim-lspconfig', - 'williamboman/nvim-lsp-installer', - - -- additional rust tools - "simrat39/rust-tools.nvim", - - -- highlight current symbol - "RRethy/vim-illuminate", - - -- lua plugin development - "folke/lua-dev.nvim", - - -- lsp status - "nvim-lua/lsp-status.nvim", - }, - config = function() require('plugins.nvim-lsp-setup') end, - } - - -- null-ls - use { - "jose-elias-alvarez/null-ls.nvim", - config = function() - require("null-ls").setup({ - sources = { - require("null-ls").builtins.formatting.prettier, - }, - on_attach = function(client) - local utils = require("nvim-lsp-setup.utils") - utils.format_on_save(client) - end, - }) - end, - } -end) diff --git a/nvim/lua/plugins/bufferline.lua b/nvim/lua/plugins/bufferline.lua deleted file mode 100644 index 6d4163d..0000000 --- a/nvim/lua/plugins/bufferline.lua +++ /dev/null @@ -1,19 +0,0 @@ -require('bufferline') - --- format as ". " -local tabname_format = function (opts) - return string.format('%s.', opts.ordinal) -end - -require('bufferline').setup({ - options = { - always_show_bufferline = true, - numbers = tabname_format, - show_buffer_icons = true, - show_buffer_close_icons = false, - show_close_icon = false, - --separator_style = 'slant', - }, - -- Don't use italic on current buffer - highlights = {buffer_selected = { gui = "bold" },}, -}) diff --git a/nvim/lua/plugins/nvim-lsp-setup.lua b/nvim/lua/plugins/nvim-lsp-setup.lua deleted file mode 100644 index 0f16626..0000000 --- a/nvim/lua/plugins/nvim-lsp-setup.lua +++ /dev/null @@ -1,65 +0,0 @@ -local lsp_status = require("lsp-status") -lsp_status.config({ - current_function = false, - show_filename = false, - diagnostics = true, -}) -lsp_status.register_progress() - -local utils = require("nvim-lsp-setup.utils") - -require("nvim-lsp-setup").setup({ - default_mappings = false, - mappings = { - gD = "lua vim.lsp.buf.declaration()", - gd = "Telescope lsp_definitions", - gt = "Telescope lsp_type_definitions", - gi = "Telescope lsp_implementations", - gr = "Telescope lsp_references", - K = "lua vim.lsp.buf.hover()", - [""] = "lua vim.lsp.buf.signature_help()", - ["rn"] = "lua vim.lsp.buf.rename()", - ["ca"] = "lua vim.lsp.buf.code_action()", - ["f"] = "lua vim.lsp.buf.formatting()", - ["e"] = "lua vim.lsp.diagnostic.show_line_diagnostics()", - ["d"] = "Telescope diagnostics", - [""] = "lua vim.diagnostic.goto_prev()", - [""] = "lua vim.diagnostic.goto_next()", - }, - on_attach = function(client) - utils.format_on_save(client) - require("illuminate").on_attach(client) - lsp_status.on_attach(client) - end, - capabilities = vim.tbl_extend("keep", vim.lsp.protocol.make_client_capabilities(), lsp_status.capabilities), - servers = { - ansiblels = {}, - bashls = {}, - dockerls = {}, - eslint = {}, - jsonls = {}, - pylsp = {}, - rnix = {}, - rust_analyzer = require("nvim-lsp-setup.rust-tools").setup({ - server = { - settings = { - ["rust-analyzer"] = { - cargo = { - loadOutDirsFromCheck = true, - }, - checkOnSave = { command = "clippy" }, - procMacro = { - enable = true, - }, - }, - }, - }, - }), - sumneko_lua = require('lua-dev').setup({}), - taplo = {}, - terraformls = {}, - tflint = {}, - volar = {}, - yamlls = {}, - }, -}) diff --git a/nvim/lualine.lua b/nvim/lualine.lua new file mode 100644 index 0000000..982987a --- /dev/null +++ b/nvim/lualine.lua @@ -0,0 +1,7 @@ +require('lualine').setup({ + options = { globalstatus = true }, + sections = { + lualine_c = { { "filename", path = 1 }, "require('lsp-status').status()" } + }, + extensions = { "toggleterm" } +}) diff --git a/nvim/luasnip.lua b/nvim/luasnip.lua new file mode 100644 index 0000000..80309d7 --- /dev/null +++ b/nvim/luasnip.lua @@ -0,0 +1 @@ +require("luasnip.loaders.from_vscode").lazy_load() diff --git a/nvim/notify.lua b/nvim/notify.lua new file mode 100644 index 0000000..6fd7a22 --- /dev/null +++ b/nvim/notify.lua @@ -0,0 +1,2 @@ +require("notify").setup({ stages = "fade" }) +vim.notify = require("notify") diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/nvim-cmp.lua similarity index 100% rename from nvim/lua/plugins/nvim-cmp.lua rename to nvim/nvim-cmp.lua diff --git a/nvim/lua/options.lua b/nvim/options.lua similarity index 100% rename from nvim/lua/options.lua rename to nvim/options.lua diff --git a/nvim/tabline.lua b/nvim/tabline.lua new file mode 100644 index 0000000..74da8bb --- /dev/null +++ b/nvim/tabline.lua @@ -0,0 +1 @@ +require('tabline').setup({ enable = true, options = { show_bufnr = true, show_filename_only = true } }) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/telescope.lua similarity index 100% rename from nvim/lua/plugins/telescope.lua rename to nvim/telescope.lua diff --git a/nvim/lua/themes.lua b/nvim/themes.lua similarity index 53% rename from nvim/lua/themes.lua rename to nvim/themes.lua index 3101cab..96d2d9b 100644 --- a/nvim/lua/themes.lua +++ b/nvim/themes.lua @@ -1,2 +1,2 @@ -vim.opt.background = 'dark' +vim.opt.background = 'light' vim.cmd("colorscheme solarized") diff --git a/nvim/toggleterm.lua b/nvim/toggleterm.lua new file mode 100644 index 0000000..37cbe4c --- /dev/null +++ b/nvim/toggleterm.lua @@ -0,0 +1 @@ +require("toggleterm").setup({ size = 32, open_mapping = [[]] }) diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/treesitter.lua similarity index 100% rename from nvim/lua/plugins/treesitter.lua rename to nvim/treesitter.lua