Skip to content

Commit

Permalink
Move to new 0.7 lua APIs and global statusbar
Browse files Browse the repository at this point in the history
Signed-off-by: Micah Halter <micah@balena.io>
  • Loading branch information
bryant-the-coder authored and mehalter committed Apr 5, 2022
1 parent b8ecb60 commit 71d13bc
Show file tree
Hide file tree
Showing 15 changed files with 336 additions and 218 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<img src="https://img.shields.io/github/license/kabinspace/AstroVim?label=License&logo=GNU&style=flat-square"/>
</a>
<a href="https://neovim.io/">
<img src="https://img.shields.io/badge/Neovim-0.6+-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=white"/>
<img src="https://img.shields.io/badge/Neovim-0.7+-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=white"/>
</a>
<a href="https://discord.gg/UcZutyeaFW">
<img src="https://img.shields.io/badge/discord-Join-7289da?color=%235865F2%20&label=Discord&logo=discord&logoColor=%23ffffff&style=flat-square"/>
Expand Down Expand Up @@ -36,11 +36,13 @@ things easier and more "future-proof".
## ⚡ Requirements

- [Nerd Fonts](https://www.nerdfonts.com/font-downloads)
- [Neovim 0.6+](https://github.com/neovim/neovim/releases/tag/v0.6.1)
- [Neovim 0.7+](https://github.com/neovim/neovim/releases/tag/v0.7.0)
- Terminal with true color support (for the default theme, otherwise it is dependent on the theme you are using)

> Note when using default theme: For MacOS, the default terminal does not have true color support. You wil need to use [iTerm2](https://iterm2.com/) or another [terminal emulator](https://gist.github.com/XVilka/8346728#terminal-emulators) that has true color support.
> Note if you are still on Neovim v0.6: You can still install the previous version of AstroVim that supported. After cloning the repository run `git checkout nvim-0.6` to check out this version. This will no longer be receiving updates.
## 🛠️ Installation

### Linux
Expand Down
8 changes: 2 additions & 6 deletions colors/default_theme.vim → colors/default_theme.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
" Author: Kabin Karki <kabinkarki555@gmail.com>

lua << EOF
vim.g.colors_name = "default_theme"

package.loaded["default_theme"] = nil
package.loaded["default_theme.base"] = nil
package.loaded["default_theme.treesitter"] = nil
package.loaded["default_theme.lsp"] = nil
package.loaded["default_theme.others"] = nil

require("default_theme")

EOF
require "default_theme"
2 changes: 1 addition & 1 deletion lua/configs/lsp/handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ M.on_attach = function(client, bufnr)
on_attach_override(client, bufnr)
end

vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
vim.api.nvim_add_user_command("Format", vim.lsp.buf.formatting, {})
lsp_highlight_document(client)
end

Expand Down
1 change: 1 addition & 0 deletions lua/configs/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function M.config()
disabled_filetypes = { "NvimTree", "neo-tree", "dashboard", "Outline" },
component_separators = "",
section_separators = "",
globalstatus = vim.fn.has "nvim-0.7" == 1,
},
sections = {
lualine_a = { spacer },
Expand Down
66 changes: 42 additions & 24 deletions lua/core/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,52 @@ local M = {}
local utils = require "core.utils"
local config = utils.user_settings()

vim.cmd [[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]]
local cmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
local add_command = vim.api.nvim_add_user_command

vim.cmd [[
augroup cursor_off
autocmd!
autocmd WinLeave * set nocursorline
autocmd WinEnter * set cursorline
augroup end
]]
augroup("packer_user_config", {})
cmd("BufWritePost", {
desc = "Auto Compile plugins.lua file",
group = "packer_user_config",
command = "source <afile> | PackerCompile",
pattern = "plugins.lua",
})

augroup("cursor_off", {})
cmd("WinLeave", {
desc = "No cursorline",
group = "cursor_off",
command = "set nocursorline",
})
cmd("WinEnter", {
desc = "No cursorline",
group = "cursor_off",
command = "set cursorline",
})

if config.enabled.dashboard and config.enabled.bufferline then
vim.cmd [[
augroup dashboard_settings
autocmd!
autocmd FileType dashboard set showtabline=0
autocmd BufWinLeave <buffer> set showtabline=2
autocmd BufEnter * if &ft is "dashboard" | set nocursorline | endif
augroup end
]]
augroup("dashboard_settings", {})
cmd("FileType", {
desc = "Disable tabline for dashboard",
group = "dashboard_settings",
pattern = "dashboard",
command = "set showtabline=0",
})
cmd("BufWinLeave", {
desc = "Reenable tabline when leaving dashboard",
group = "dashboard_settings",
pattern = "<buffer>",
command = "set showtabline=2",
})
cmd("BufEnter", {
desc = "No cursorline on dashboard",
group = "dashboard_settings",
pattern = "*",
command = "if &ft is 'dashboard' | set nocursorline | endif",
})
end

vim.cmd [[
command! AstroUpdate lua require('core.utils').update()
]]
add_command("AstroUpdate", require("core.utils").update, {})

return M
2 changes: 1 addition & 1 deletion lua/core/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local config = {
},

default_theme = {
diagnostics_style = "none",
diagnostics_style = {},
},

enabled = {
Expand Down

0 comments on commit 71d13bc

Please sign in to comment.