fix: OOP fixes (lua is weird), statusline rename
This commit is contained in:
parent
0ddcf99657
commit
8ffbe73ff7
4 changed files with 46 additions and 41 deletions
9
init.lua
9
init.lua
|
@ -55,7 +55,7 @@ vim.opt.showtabline = 1 -- set to 2 to always show tabline
|
|||
-- Statusline
|
||||
STATUSLINE = require('statusline')
|
||||
vim.opt.laststatus = 3 -- show one global statusline
|
||||
vim.opt.statusline = "%!v:lua.STATUSLINE:display()"
|
||||
vim.opt.statusline = "%!v:lua.STATUSLINE.display()"
|
||||
|
||||
|
||||
-- Netrw settings
|
||||
|
@ -113,10 +113,13 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
|||
local packer_bootstrap = vim.fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
|
||||
end
|
||||
|
||||
plugins = require('plugins')
|
||||
PLUGINS = require('plugins')
|
||||
|
||||
|
||||
--|| THEME
|
||||
PALETTE = require('colors')
|
||||
|
||||
PALETTE:set_colors()
|
||||
|
||||
|
||||
--|| UTILITY
|
||||
function P(something) print(vim.inspect(something)) end
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
&&&
|
||||
]]--
|
||||
|
||||
local MAPPINGS = { }
|
||||
local KEYBINDS = { }
|
||||
|
||||
--|| GLOBAL KEYBINDS
|
||||
function MAPPINGS:set_global_keys(opts)
|
||||
function KEYBINDS:set_global_keys(opts)
|
||||
-- Quick settings
|
||||
vim.keymap.set('n', '<F10>', ':set hls!<CR>', opts)
|
||||
vim.keymap.set('n', '<F9>', ':set wrap!<CR>', opts)
|
||||
|
@ -40,7 +40,7 @@ function MAPPINGS:set_global_keys(opts)
|
|||
vim.keymap.set('t', '<ESC>', '<C-\\><C-n>', opts)
|
||||
end
|
||||
|
||||
function MAPPINGS:set_navigation_keys(opts)
|
||||
function KEYBINDS:set_navigation_keys(opts)
|
||||
-- lazy arrow scrolling
|
||||
vim.keymap.set('n', '<S-Up>', '<C-u>', opts)
|
||||
vim.keymap.set('n', '<S-Down>', '<C-d>', opts)
|
||||
|
@ -52,7 +52,7 @@ function MAPPINGS:set_navigation_keys(opts)
|
|||
vim.keymap.set('n', '<M-Left>', ':vertical resize -1<CR>', opts)
|
||||
end
|
||||
|
||||
function MAPPINGS:set_lsp_keys(opts)
|
||||
function KEYBINDS:set_lsp_keys(opts)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(opts.buffer, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
-- Enable Lsp tagfunc
|
||||
|
@ -77,7 +77,7 @@ function MAPPINGS:set_lsp_keys(opts)
|
|||
vim.api.nvim_create_user_command('Format', ':lua vim.lsp.buf.formatting()<CR>', {}) -- TODO if function is passed directly, it doesn't work!
|
||||
end
|
||||
|
||||
function MAPPINGS:set_telescope_keys(opts)
|
||||
function KEYBINDS:set_telescope_keys(opts)
|
||||
-- File navigation
|
||||
vim.keymap.set('n', '<C-f>', ':Telescope find_files<CR>', opts)
|
||||
vim.keymap.set('n', 'F', ':Telescope find_files<CR>', opts) -- fallback for windows
|
||||
|
@ -101,4 +101,4 @@ function MAPPINGS:set_telescope_keys(opts)
|
|||
vim.keymap.set('n', '<C-PageDown>', ':Telescope diagnostics bufnr=0<CR>', opts)
|
||||
end
|
||||
|
||||
return MAPPINGS
|
||||
return KEYBINDS
|
||||
|
|
|
@ -144,7 +144,7 @@ local init_fn = function(use)
|
|||
local lspconfig = require("lspconfig")
|
||||
|
||||
local function set_lsp_binds(_, bufnr)
|
||||
require('keybinds').set_lsp_keys({buffer=bufnr})
|
||||
require('keybinds'):set_lsp_keys({buffer=bufnr})
|
||||
end
|
||||
|
||||
local rust_tools = require("rust-tools")
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
--[[
|
||||
|
||||
GJ5GPP# #### ██████╗ ██╗██╗ ██╗███████╗
|
||||
5:. !5 #^!??7B ██╔══██╗██║██║ ██╔╝██╔════╝
|
||||
!Y ###########7^ ██████╔╝██║█████╔╝ █████╗
|
||||
G ~J?JJJJJJJJJJ^? ██╔══██╗██║██╔═██╗ ██╔══╝
|
||||
#^!:# G 5 ██████╔╝██║██║ ██╗███████╗
|
||||
#G5JJ?JJ5:?@J: #?7J.JJ?JJYPB ╚═════╝ ╚═╝╚═╝ ╚═╝╚══════╝
|
||||
#?!JPBB##G.~77B!! #J~!7??.B##BGY7!P
|
||||
P:Y# ^? P:J:Y 5~J~J# ?7 B~! * simple statusbar for
|
||||
B.G ~7 #.Y.G G!?#~? ~Y ~7 when you'd rather
|
||||
J: 7.YYY55G:!?.7!B #.B #~B P. use something you
|
||||
P.# BBGGPPPY 7Y7P :Y # 7^ can fix yourself
|
||||
?^B #~7 G:5 J:B
|
||||
P~7P## #P?~5 B!!YB# #BY~7# * by alemidev <me@alemi.dev>
|
||||
GJ?7???7?JG BY?7???77?5#
|
||||
### #### * inspired by airline, but
|
||||
straight and simpler
|
||||
GJ5GPP# #### ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗ ██████╗██╗ ███████╗
|
||||
5:. !5 #^!??7B ██╔══██╗██╔══██╗██╔══██╗██╔════╝╚██╗ ██╔╝██╔════╝██║ ██╔════╝
|
||||
!Y ###########7^ ██████╔╝███████║██████╔╝██║ ╚████╔╝ ██║ ██║ █████╗
|
||||
G ~J?JJJJJJJJJJ^? ██╔══██╗██╔══██║██╔══██╗██║ ╚██╔╝ ██║ ██║ ██╔══╝
|
||||
#^!:# G 5 ██████╔╝██║ ██║██║ ██║╚██████╗ ██║ ╚██████╗███████╗███████╗
|
||||
#G5JJ?JJ5:?@J: #?7J.JJ?JJYPB ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝╚══════╝╚══════╝
|
||||
#?!JPBB##G.~77B!! #J~!7??.B##BGY7!P
|
||||
P:Y# ^? P:J:Y 5~J~J# ?7 B~! * simple statusbar for * inspired by airline,
|
||||
B.G ~7 #.Y.G G!?#~? ~Y ~7 when you'd rather but without the
|
||||
J: 7.YYY55G:!?.7!B #.B #~B P. use something you arrow things and
|
||||
P.# BBGGPPPY 7Y7P :Y # 7^ can fix yourself way simpler
|
||||
?^B #~7 G:5 J:B
|
||||
P~7P## #P?~5 B!!YB# #BY~7# * by alemidev <me@alemi.dev> * drive less, bike more!
|
||||
GJ?7???7?JG BY?7???77?5#
|
||||
### ####
|
||||
|
||||
]]--
|
||||
|
||||
--- global statusline object
|
||||
local STATUSLINE = {
|
||||
local BARCYCLE = {
|
||||
mode_string = {
|
||||
['n' ] = 'NORMAL',
|
||||
['no'] = 'NORMAL op',
|
||||
|
@ -64,7 +64,7 @@ local STATUSLINE = {
|
|||
},
|
||||
}
|
||||
|
||||
function STATUSLINE:linter()
|
||||
function BARCYCLE:linter()
|
||||
local n_warns = 0
|
||||
local warns = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
|
||||
if warns ~= nil then n_warns = #warns end
|
||||
|
@ -80,14 +80,14 @@ function STATUSLINE:linter()
|
|||
end
|
||||
end
|
||||
|
||||
function STATUSLINE:combo()
|
||||
function BARCYCLE:combo()
|
||||
if vim.g.combo ~= nil then
|
||||
return vim.g.combo
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
function STATUSLINE:git()
|
||||
function BARCYCLE:git()
|
||||
if vim.fn['fugitive#Head']() ~= nil then
|
||||
return vim.fn['fugitive#Head']()
|
||||
else
|
||||
|
@ -95,7 +95,7 @@ function STATUSLINE:git()
|
|||
end
|
||||
end
|
||||
|
||||
function STATUSLINE:lsp()
|
||||
function BARCYCLE:lsp()
|
||||
local clients = vim.lsp.buf_get_clients(0)
|
||||
if #clients > 0 then
|
||||
local client_names = {}
|
||||
|
@ -108,24 +108,26 @@ function STATUSLINE:lsp()
|
|||
end
|
||||
end
|
||||
|
||||
function STATUSLINE:display()
|
||||
function BARCYCLE:statusline()
|
||||
local mode = vim.fn.mode()
|
||||
local line = {
|
||||
self.mode_highlight[mode] .. " " .. self.mode_string[mode],
|
||||
"%#StatusLineBlock# %Y",
|
||||
"%{v:lua.statusline.combo()}",
|
||||
"%{v:lua.statusline.linter()}",
|
||||
"%#StatusLineBlock# %Y", -- type of file
|
||||
self:combo(),
|
||||
self:linter(),
|
||||
"%#StatusLine#",
|
||||
"%{v:lua.statusline.git()}",
|
||||
"%r%h%w%m %<%F ",
|
||||
self:git(),
|
||||
"%r%h%w%m %<%F ", -- file flags (RO, HELP, PREVIEW, MODIFY), file path
|
||||
"%=", -- change alignment
|
||||
"%{v:lua.statusline.lsp()}",
|
||||
self:lsp(),
|
||||
"%{&fileencoding?&fileencoding:&encoding}",
|
||||
"%{&fileformat}",
|
||||
"%#StatusLineBlock# %3l:%-3c %3p%%",
|
||||
self.mode_highlight[mode] .. " %n " .. "%0*"
|
||||
"%#StatusLineBlock# %3l:%-3c %3p%%", -- cursor coordinates: line (formatted), column (formatted), percentage (formatted)
|
||||
self.mode_highlight[mode] .. " %n " .. "%0*" -- buffer number
|
||||
}
|
||||
return table.concat(line, " ")
|
||||
end
|
||||
|
||||
return STATUSLINE
|
||||
function BARCYCLE.display() return BARCYCLE:statusline() end
|
||||
|
||||
return BARCYCLE
|
||||
|
|
Loading…
Reference in a new issue