diff options
| Commit | b36fbab879afb0931806b29d976efc3c69fb409d (patch) | |
|---|---|---|
| Author | 2024-08-05 13:26:29 +0300 | |
| Committer | 2024-08-05 13:26:29 +0300 | |
| Files | 473203563e1eb6a551d41ed81d62e59d3b1a0767 /lua | |
| anderson-b36fbab879afb0931806b29d976efc3c69fb409d.tar anderson-b36fbab879afb0931806b29d976efc3c69fb409d.tar.gz anderson-b36fbab879afb0931806b29d976efc3c69fb409d.zip | ||
| Parent | 34a94913f37d9db03489f4a4a86ef63e2fa07c14 (diff) | |
feat(all)!: Replaced plugin manager vim-plug with lazy.nvim
6 files changed, 229 insertions, 174 deletions
| -rw-r--r-- | lua/config/lazy.lua | 35 | ||||
| -rw-r--r-- | lua/lsp.lua | 13 | ||||
| -rw-r--r-- | lua/plugins.lua | 29 | ||||
| -rw-r--r-- | lua/plugins/default.lua | 29 | ||||
| -rw-r--r-- | lua/plugins/heirline.lua | 270 | ||||
| -rw-r--r-- | lua/plugins/lsp-config.lua | 27 |
diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/lsp.lua b/lua/lsp.lua deleted file mode 100644 index 5468a84..0000000 --- a/lua/lsp.lua +++ /dev/null @@ -1,13 +0,0 @@ -local lspconfig = require('lspconfig') - -lspconfig.awk_ls.setup({}) - --- Thanks https://stackoverflow.com/a/70760302/12036073 -vim.o.updatetime = 300 -vim.diagnostic.config({ - virtual_text = false, - float = { focus = false }, -}) -vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { callback = function(ev) - vim.diagnostic.open_float(nil) -end}) diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index 00db4ce..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,29 +0,0 @@ -local Plug = vim.fn['plug#'] -vim.call('plug#begin') - -Plug("morhetz/gruvbox") -- Color theme -Plug("nvim-treesitter/nvim-treesitter") -Plug("neovim/nvim-lspconfig") -Plug("nvim-tree/nvim-web-devicons") -Plug("rebelot/heirline.nvim") - -vim.call('plug#end') - ---[==[ gruvbox ]==]-- - -vim.o.background = "dark" -vim.g.gruvbox_contrast_dark = "hard" -vim.cmd("colorscheme gruvbox") - ---[==[ treesitter ]==]-- - -require("nvim-treesitter.configs").setup({ - ensure_installed = "all", - ignore_install = { "liquidsoap", "norg", "tlaplus", "yaml" }, -- Can't compile - highlight = { enable = true }, - incremental_selection = { enable = true }, - textobjects = { enable = true }, -}) - ---[==[ Heirline ]==]-- -require("plugins.heirline") diff --git a/lua/plugins/default.lua b/lua/plugins/default.lua new file mode 100644 index 0000000..742ef96 --- /dev/null +++ b/lua/plugins/default.lua @@ -0,0 +1,29 @@ +return { + { + "morhetz/gruvbox", + lazy = false, + priority = 1000, + init = function() + vim.o.background = "dark" + vim.g.gruvbox_contrast_dark = "hard" + end, + config = function() + vim.cmd("colorscheme gruvbox") + end, + }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + opts = { + ensure_installed = "all", + ignore_install = { "liquidsoap", "norg", "tlaplus", "yaml" }, -- Can't compile + highlight = { enable = true }, + incremental_selection = { enable = true }, + textobjects = { enable = true }, + }, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end, + }, + { "nvim-tree/nvim-web-devicons", }, +} diff --git a/lua/plugins/heirline.lua b/lua/plugins/heirline.lua index 126066a..4e30553 100644 --- a/lua/plugins/heirline.lua +++ b/lua/plugins/heirline.lua @@ -1,159 +1,165 @@ -local utils = require("heirline.utils") -local conditions = require("heirline.conditions") +return { + "rebelot/heirline.nvim", + lazy = false, + opts = function() + local utils = require("heirline.utils") + local conditions = require("heirline.conditions") ---[=[ Helpers ]=]-- + --[=[ Helpers ]=]-- -function inverseColors(highlight) - if highlight == nil then return nil end + function inverseColors(highlight) + if highlight == nil then return nil end - if type(highlight) == "string" then - highlight = utils.get_highlight(highlight) - end + if type(highlight) == "string" then + highlight = utils.get_highlight(highlight) + end - highlight.cterm = { reverse = true } - return highlight -end + highlight.cterm = { reverse = true } + return highlight + end -local delimiters = { - FilledCircle = { "", "" }, - Circle = { "", "" }, -} -local StatusLineColor = utils.get_highlight("StatusLine") + local delimiters = { + FilledCircle = { "", "" }, + Circle = { "", "" }, + } + local StatusLineColor = utils.get_highlight("StatusLine") -function surround(delimiters, component) - return { - init = function(self) - local highlight - if component.hl ~= nil and type(component.hl) == "function" then - if component.init ~= nil then - component:init() - end - highlight = component:hl() - else - highlight = component.hl - end + function surround(delimiters, component) + return { + init = function(self) + local highlight + if component.hl ~= nil and type(component.hl) == "function" then + if component.init ~= nil then + component:init() + end + highlight = component:hl() + else + highlight = component.hl + end - self.inverse = inverseColors(highlight) - self.inverse.ctermfg = StatusLineColor.ctermfg -- Actually sets bg, but both are reversed - end, + self.inverse = inverseColors(highlight) + self.inverse.ctermfg = StatusLineColor.ctermfg -- Actually sets bg, but both are reversed + end, - { - condition = function() return conditions.is_active() end, - provider = delimiters[1], - hl = function(self) return self.inverse end, - }, - component, - { - condition = function() return conditions.is_active() end, - provider = delimiters[2], - hl = function(self) return self.inverse end, - }, + { + condition = function() return conditions.is_active() end, + provider = delimiters[1], + hl = function(self) return self.inverse end, + }, + component, + { + condition = function() return conditions.is_active() end, + provider = delimiters[2], + hl = function(self) return self.inverse end, + }, - update = { "BufEnter", "BufLeave" }, - } -end + update = { "BufEnter", "BufLeave" }, + } + end ---[=[ Common elements ]=]-- + --[=[ Common elements ]=]-- -local FileStat = { - { - condition = function() - return vim.bo.readonly - end, - provider = "", - }, - { - condition = function() - return vim.bo.modified or not vim.bo.modifiable - end, - provider = function(self) - local prepend = vim.bo.readonly and " " or "" - if vim.bo.modified then return prepend.."" end - if not vim.bo.modifiable then return prepend.."" end - end, - }, -} + local FileStat = { + { + condition = function() + return vim.bo.readonly + end, + provider = "", + }, + { + condition = function() + return vim.bo.modified or not vim.bo.modifiable + end, + provider = function(self) + local prepend = vim.bo.readonly and " " or "" + if vim.bo.modified then return prepend.."" end + if not vim.bo.modifiable then return prepend.."" end + end, + }, + } -local FileType = { - static = { - get_icon = require("nvim-web-devicons").get_icon_by_filetype, - }, - provider = function(self) - local icon = self.get_icon(vim.bo.filetype) - if icon ~= nil then icon = icon.." " - else icon = "" - end - return icon..vim.bo.filetype - end, -} + local FileType = { + static = { + get_icon = require("nvim-web-devicons").get_icon_by_filetype, + }, + provider = function(self) + local icon = self.get_icon(vim.bo.filetype) + if icon ~= nil then icon = icon.." " + else icon = "" + end + return icon..vim.bo.filetype + end, + } -local Filename = { provider = "%f", } -local Space = { provider = " ", } + local Filename = { provider = "%f", } + local Space = { provider = " ", } ---[=[ Statusline ]=]-- + --[=[ Statusline ]=]-- -vim.cmd.highlight({ "ModeNormal", "ctermfg=236", "ctermbg=117" }) -vim.cmd.highlight({ "ModeInsert", "ctermfg=236", "ctermbg=119" }) -vim.cmd.highlight({ "ModeReplace", "ctermfg=236", "ctermbg=203" }) -vim.cmd.highlight({ "ModeVisual", "ctermfg=236", "ctermbg=216" }) + vim.cmd.highlight({ "ModeNormal", "ctermfg=236", "ctermbg=117" }) + vim.cmd.highlight({ "ModeInsert", "ctermfg=236", "ctermbg=119" }) + vim.cmd.highlight({ "ModeReplace", "ctermfg=236", "ctermbg=203" }) + vim.cmd.highlight({ "ModeVisual", "ctermfg=236", "ctermbg=216" }) -local Mode = surround(delimiters.FilledCircle, { - init = function(self) - self.modestr = vim.fn.mode(1) - if self.modestr == "\22" then self.modestr = "V^" - elseif self.modestr == "\22s" then self.modestr = "V^s" - end - end, + local Mode = surround(delimiters.FilledCircle, { + init = function(self) + self.modestr = vim.fn.mode(1) + if self.modestr == "\22" then self.modestr = "V^" + elseif self.modestr == "\22s" then self.modestr = "V^s" + end + end, - provider = function(self) - if not conditions.is_active() then return " " end - return self.modestr - end, - hl = function(self) - if not conditions.is_active() then return "StatusLineNC" end + provider = function(self) + if not conditions.is_active() then return " " end + return self.modestr + end, + hl = function(self) + if not conditions.is_active() then return "StatusLineNC" end - local modeletter = self.modestr:sub(1,1):lower() + local modeletter = self.modestr:sub(1,1):lower() - if modeletter == "i" then return "ModeInsert" - elseif modeletter == "r" then return "ModeReplace" - elseif modeletter == "v" then return "ModeVisual" - end + if modeletter == "i" then return "ModeInsert" + elseif modeletter == "r" then return "ModeReplace" + elseif modeletter == "v" then return "ModeVisual" + end - return "ModeNormal" - end, -}) + return "ModeNormal" + end, + }) -vim.cmd.highlight({ "RowAndColumn", "ctermfg=238", "ctermbg=244" }) + vim.cmd.highlight({ "RowAndColumn", "ctermfg=238", "ctermbg=244" }) -local LineAndColumn = surround(delimiters.FilledCircle, { - provider = function(self) - if not conditions.is_active() then - local row,col = unpack(vim.api.nvim_win_get_cursor(0)) - return string.rep(" ", 1 + tostring(row):len() + tostring(col):len()) - end - return "%l:%c" - end, - hl = function(self) - if not conditions.is_active() then return "StatusLineNC" end - return "RowAndColumn" - end, -}) + local LineAndColumn = surround(delimiters.FilledCircle, { + provider = function(self) + if not conditions.is_active() then + local row,col = unpack(vim.api.nvim_win_get_cursor(0)) + return string.rep(" ", 1 + tostring(row):len() + tostring(col):len()) + end + return "%l:%c" + end, + hl = function(self) + if not conditions.is_active() then return "StatusLineNC" end + return "RowAndColumn" + end, + }) -local LeftShrink = { provider = "%<", } -local LeftSep = { provider = " "..delimiters.Circle[2].." " } -local RightSep = { provider = " "..delimiters.Circle[1].." " } -local ExpandMiddle = { provider = "%=", } -local CursorChar = { provider = "%b", } + local LeftShrink = { provider = "%<", } + local LeftSep = { provider = " "..delimiters.Circle[2].." " } + local RightSep = { provider = " "..delimiters.Circle[1].." " } + local ExpandMiddle = { provider = "%=", } + local CursorChar = { provider = "%b", } -local StatusLine = { - Mode, LeftShrink, Space, Filename, LeftSep, FileStat, - ExpandMiddle, - CursorChar, RightSep, FileType, Space, LineAndColumn -} + local StatusLine = { + Mode, LeftShrink, Space, Filename, LeftSep, FileStat, + ExpandMiddle, + CursorChar, RightSep, FileType, Space, LineAndColumn + } ---[=[ Setup ]=]-- + --[=[ Setup ]=]-- -require("heirline").setup({ - statusline = StatusLine, -}) + return { + statusline = StatusLine, + } + end, +} diff --git a/lua/plugins/lsp-config.lua b/lua/plugins/lsp-config.lua new file mode 100644 index 0000000..2ca9ac5 --- /dev/null +++ b/lua/plugins/lsp-config.lua @@ -0,0 +1,27 @@ +-- Thanks https://stackoverflow.com/a/70760302/12036073 +vim.o.updatetime = 300 +vim.diagnostic.config({ + virtual_text = false, + float = { focus = false }, +}) +vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { callback = function(ev) + vim.diagnostic.open_float(nil) +end}) + +return { + { + "neovim/nvim-lspconfig", + enabled = false, -- Figure out config property + event = { "BufReadPre", "BufNewFile" }, + -- dependencies = { + -- "mason.nvim", + -- { "williamboman/mason-lspconfig.nvim", config = function() end }, + -- }, + opts = { + servers = { + awk_ls = { settings = {}, }, + }, + }, + setup = {}, + }, +} |
