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