aboutsummaryrefslogtreecommitdiff
path: root/lua/pml68/settings.lua
blob: f862d85ff1ed18e41ee3f9c60f57415a0027b808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
vim.o.rnu = true
vim.o.nu = true

vim.o.conceallevel = 2

vim.o.laststatus = 3

local function branch_name()
  local branch = vim.fn.system("git branch --show-current 2> /dev/null | tr -d '\n'")
  if branch ~= "" then
    return " " .. branch
  else
    return ""
  end
end


local function get_attached_clients()
	local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 })
	if #buf_clients == 0 then
		return "LSP Inactive"
	end

	local buf_ft = vim.bo.filetype
	local buf_client_names = {}

	for _, client in pairs(buf_clients) do
			table.insert(buf_client_names, client.name)
	end

	local unique_client_names = {}
	for _, client_name_target in ipairs(buf_client_names) do
		local is_duplicate = false
		for _, client_name_compare in ipairs(unique_client_names) do
			if client_name_target == client_name_compare then
				is_duplicate = true
			end
		end
		if not is_duplicate then
			table.insert(unique_client_names, client_name_target)
		end
	end

	local client_names_str = table.concat(unique_client_names, ", ")
	local language_servers = string.format("[%s]", client_names_str)

	return language_servers
end

vim.api.nvim_create_autocmd({ "FileType", "BufEnter", "FocusGained" }, {
  callback = function()
    vim.b.branch_name = branch_name()
  end
})

function Status_Line()
  return " "
      .. "%<"
      .. " %f "
      .. vim.b.branch_name
      .. " %m"
      .. " %= "
      .. get_attached_clients()
      .. " [%{&filetype}]"
      .. " %l:%c "
end

vim.opt.statusline = "%{%v:lua.Status_Line()%}"

vim.o.shiftwidth = 2
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.expandtab = true

vim.o.mouse = "a"

vim.o.smartindent = true

vim.o.swapfile = false
vim.o.backup = false

vim.o.scrolloff = 10
vim.o.cursorline = false

vim.o.hlsearch = true
vim.o.incsearch = true

vim.o.clipboard = "unnamedplus"

vim.opt.whichwrap:append "<>[]hl"

vim.o.foldmethod = "expr"
vim.o.foldenable = false
vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"

vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. ":" .. vim.env.PATH