summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito G. Graffagnino <vito@graffagnino.xyz>2022-06-03 17:54:52 +0100
committerVito G. Graffagnino <vito@graffagnino.xyz>2022-06-03 17:54:52 +0100
commitc8257b7161b2004d9d4fdae2af73b48b327f4487 (patch)
tree4c8a5169a84f0a955a11de2ba9a5a45b2835a89b
parent1313031ffade5e5008d44eb11fa93d6e8cdcd041 (diff)
parent24a4adc76f254309993eca04a79722bd1aea32ac (diff)
Merge branch '15-lualine.lua' into vgg
-rw-r--r--init.lua1
-rw-r--r--lua/user/lsp/null-ls.lua22
-rw-r--r--lua/user/lualine.lua93
-rw-r--r--lua/user/plugins.lua4
4 files changed, 108 insertions, 12 deletions
diff --git a/init.lua b/init.lua
index 0553fef..184a4df 100644
--- a/init.lua
+++ b/init.lua
@@ -12,3 +12,4 @@ require "user.comment"
require "user.gitsigns"
require "user.nvim-tree"
require "user.bufferline"
+require "user.lualine"
diff --git a/lua/user/lsp/null-ls.lua b/lua/user/lsp/null-ls.lua
index ec79994..b261418 100644
--- a/lua/user/lsp/null-ls.lua
+++ b/lua/user/lsp/null-ls.lua
@@ -1,20 +1,18 @@
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
if not null_ls_status_ok then
- return
-end
+ return
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
local formatting = null_ls.builtins.formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
local diagnostics = null_ls.builtins.diagnostics
-null_ls.setup {
- debug = false,
- sources = {
- formatting.prettier.with { extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } },
- formatting.black.with { extra_args = { "--fast" } },
- -- formatting.yapf,
- formatting.stylua,
- diagnostics.flake8,
- },
-}
+null_ls.setup({
+ debug = false,
+ sources = {
+ formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
+ formatting.black.with({ extra_args = { "--fast" } }),
+ formatting.stylua,
+ diagnostics.flake8
+ },
+})
diff --git a/lua/user/lualine.lua b/lua/user/lualine.lua
new file mode 100644
index 0000000..50484cb
--- /dev/null
+++ b/lua/user/lualine.lua
@@ -0,0 +1,93 @@
+local status_ok, lualine = pcall(require, "lualine")
+if not status_ok then
+ return
+end
+
+local hide_in_width = function()
+ return vim.fn.winwidth(0) > 80
+end
+
+local diagnostics = {
+ "diagnostics",
+ sources = { "nvim_diagnostic" },
+ sections = { "error", "warn" },
+ symbols = { error = " ", warn = " " },
+ colored = false,
+ update_in_insert = false,
+ always_visible = true,
+}
+
+local diff = {
+ "diff",
+ colored = false,
+ symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
+ cond = hide_in_width
+}
+
+local mode = {
+ "mode",
+ fmt = function(str)
+ return "-- " .. str .. " --"
+ end,
+}
+
+local filetype = {
+ "filetype",
+ icons_enabled = false,
+ icon = nil,
+}
+
+local branch = {
+ "branch",
+ icons_enabled = true,
+ icon = "",
+}
+
+local location = {
+ "location",
+ padding = 0,
+}
+
+-- cool function for progress
+local progress = function()
+ local current_line = vim.fn.line(".")
+ local total_lines = vim.fn.line("$")
+ local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
+ local line_ratio = current_line / total_lines
+ local index = math.ceil(line_ratio * #chars)
+ return chars[index]
+end
+
+local spaces = function()
+ return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
+end
+
+lualine.setup({
+ options = {
+ icons_enabled = true,
+ theme = "auto",
+ component_separators = { left = "", right = "" },
+ section_separators = { left = "", right = "" },
+ disabled_filetypes = { "dashboard", "NvimTree", "Outline" },
+ always_divide_middle = true,
+ },
+ sections = {
+ lualine_a = { branch, diagnostics },
+ lualine_b = { mode },
+ lualine_c = {},
+ -- lualine_x = { "encoding", "fileformat", "filetype" },
+ lualine_x = { diff, spaces, "encoding", filetype },
+ lualine_y = { location },
+ lualine_z = { progress },
+ },
+ inactive_sections = {
+ lualine_a = {},
+ lualine_b = {},
+ lualine_c = { "filename" },
+ lualine_x = { "location" },
+ lualine_y = {},
+ lualine_z = {},
+ },
+ tabline = {},
+ extensions = {},
+})
diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua
index bb45cb1..1af5c97 100644
--- a/lua/user/plugins.lua
+++ b/lua/user/plugins.lua
@@ -50,6 +50,9 @@ return packer.startup(function(use)
use "kyazdani42/nvim-tree.lua"
use "akinsho/bufferline.nvim"
use "moll/vim-bbye"
+ use 'nvim-lualine/lualine.nvim'
+ use 'kyazdani42/nvim-web-devicons'
+ use 'kyazdani42/nvim-tree.lua'
-- Colorschemes
use "lunarvim/colorschemes" -- A bunch of colorschemes you can try out
@@ -73,6 +76,7 @@ return packer.startup(function(use)
-- LSP
use "neovim/nvim-lspconfig" -- enable LSP
use "williamboman/nvim-lsp-installer" -- simple to use language server installer
+ use "tamago324/nlsp-settings.nvim" -- language server settings defined in json for
use "jose-elias-alvarez/null-ls.nvim" -- for formatters and linters
-- Telescope