nvim: re-add nvim-cokeline as a tabline option

heirline's way of making buflist is quite complicated to my taste.

Also add more LSP servers.
This commit is contained in:
Hoang Nguyen 2023-06-14 00:00:00 +07:00
parent 708b6c13c0
commit 9d624a0048
Signed by: folliehiyuki
GPG Key ID: B0567C20730E9B11
16 changed files with 219 additions and 80 deletions

15
TODO.md
View File

@ -49,26 +49,19 @@ Plans for the future of this dotfiles.
- [ ] OneDark theme
- [ ] Catppuccin theme
### Configuration
- [ ] heirline.nvim option for tabline
## LSP/DAP
- [ ] fennel-ls
- [ ] elixirls
- [ ] elixirls (config for `nvim-lspconfig` and `nvim-dap` + install script)
- [ ] erlangls (config for `nvim-lspconfig` + install script)
- [ ] clojure_lsp
- [ ] denols
- [ ] flux_lsp
- [ ] nil_ls / rnix
- [ ] qml_lsp / qmlls
- [ ] taplo
- [ ] teal
- [ ] teal_ls
- [ ] vuels
- [ ] starlark
- [ ] starlark / buck2
- [ ] ocaml
- [ ] haskell
- [ ] ruff + pylyzer instead of pylsp
### Interesting plugins

View File

@ -18,6 +18,7 @@ vim.filetype.add {
tmpl = 'gohtmltmpl',
typ = 'typst',
vifm = 'vim',
ncl = 'nickel',
},
pattern = {
['${HOME}/.kube/config'] = 'yaml',

View File

@ -1,7 +1,7 @@
{
"LuaSnip": { "branch": "master", "commit": "a13af80734eb28f744de6c875330c9d3c24b5f3b" },
"SchemaStore.nvim": { "branch": "main", "commit": "f323ed8e03d2484a1abdaa267b839315f4b34c80" },
"aerial.nvim": { "branch": "master", "commit": "aff1bb8fecff83d3e3a2d544c4d4e6d65718bd19" },
"aerial.nvim": { "branch": "master", "commit": "097fb436b2632b9546fddd13623da75d3674a704" },
"alpha-nvim": { "branch": "main", "commit": "9e33db324b8bb7a147bce9ea5496686ee859461d" },
"better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" },
"carbon-now.nvim": { "branch": "main", "commit": "c2eaf707fe591f2db3b0117261c878bdbebf568d" },
@ -16,11 +16,11 @@
"dial.nvim": { "branch": "master", "commit": "b3916370c24c498117a4c790b2752c437dab661a" },
"diffview.nvim": { "branch": "main", "commit": "0ad3e4f834093412ebbf317b7eaa9c59568824b9" },
"dressing.nvim": { "branch": "master", "commit": "f16d7586fcdd8b2e3850d0abb7e46f944125cc25" },
"emmylua-nvim": { "branch": "master", "commit": "d76ca1875e396956484c4cb6165042fd2674908d" },
"emmylua-nvim": { "branch": "master", "commit": "96af727f91a1d98e16a20b5c7226d81940187131" },
"flit.nvim": { "branch": "main", "commit": "f60e4b3d49bb5a5e97cfffe66f2e671eb422078e" },
"friendly-snippets": { "branch": "main", "commit": "49ca2a0e0e26427b550b1f64272d7fe7e4d7d51b" },
"git-conflict.nvim": { "branch": "main", "commit": "3c89812a83ac749b8851a473863958325a1cd57c" },
"gitsigns.nvim": { "branch": "main", "commit": "4455bb5364d29ff86639dfd5533d4fe4b48192d4" },
"gitsigns.nvim": { "branch": "main", "commit": "4bbfb06cf706d14912fd1962a40280c1b1138965" },
"headlines.nvim": { "branch": "master", "commit": "ddef41b2664f0ce25fe76520d708e2dc9dfebd70" },
"heirline.nvim": { "branch": "master", "commit": "2a151df2dc870e79b138a59ebaaaddf3d1b0d703" },
"inc-rename.nvim": { "branch": "main", "commit": "ed0f6f2b917cac4eb3259f907da0a481b27a3b7e" },
@ -38,16 +38,17 @@
"mini.move": { "branch": "main", "commit": "3afd39873eb9171684e554a214c055482444a47d" },
"mini.pairs": { "branch": "main", "commit": "963b800d0524eadd297199207011b98684205ada" },
"mini.surround": { "branch": "main", "commit": "14f418209ecf52d1a8de9d091eb6bd63c31a4e01" },
"neoconf.nvim": { "branch": "main", "commit": "bf802bff605d439f0403d55d83e8f6bf7247fce8" },
"neoconf.nvim": { "branch": "main", "commit": "303210e58359fbca0e94a363a370f75a57ca0aaa" },
"neogen": { "branch": "main", "commit": "1dd0319ccf41b2498f45a3c7607f2ee325ffc6a0" },
"neogit": { "branch": "master", "commit": "68a3e90e9d1ed9e362317817851d0f34b19e426b" },
"neotest": { "branch": "master", "commit": "0207e4025e5558fdd0b3951f250689eede5c75b2" },
"neotest-go": { "branch": "main", "commit": "4e7a87967e45f2b357fd546b0b7877774191772e" },
"neotest-python": { "branch": "master", "commit": "6c06041cfb45f45e276068020baa06c06fe20d5c" },
"noice.nvim": { "branch": "main", "commit": "a3318600bc1eba2cca84e879048c1ab8d4a0262d" },
"nui.nvim": { "branch": "main", "commit": "f008972ac7d24f7188521a7f8d158aac2fb0b07e" },
"nui.nvim": { "branch": "main", "commit": "9e7739e9dd2dc852a498478649cd10848e6e7b79" },
"null-ls.nvim": { "branch": "main", "commit": "a138b14099e9623832027ea12b4631ddd2a49256" },
"nvim-cmp": { "branch": "main", "commit": "b8c2a62b3bd3827aa059b43be3dd4b5c45037d65" },
"nvim-cokeline": { "branch": "main", "commit": "7fb6753c8fb90eebb6b56f86fc6e65468a23c81c" },
"nvim-coverage": { "branch": "main", "commit": "8fcc71e01e93f305e334b59f902e545a70d0050f" },
"nvim-dap": { "branch": "master", "commit": "7c1d47cf7188fc31acdf951f9eee22da9d479152" },
"nvim-dap-ui": { "branch": "master", "commit": "c020f660b02772f9f3d11f599fefad3268628a9e" },
@ -57,14 +58,14 @@
"nvim-scrollbar": { "branch": "main", "commit": "35f99d559041c7c0eff3a41f9093581ceea534e8" },
"nvim-spectre": { "branch": "master", "commit": "8adb05dbfbd36862d700b5c3d1c26f0febf3f10d" },
"nvim-tree.lua": { "branch": "master", "commit": "f873625d0636889af4cd47a01e486beb865db205" },
"nvim-treesitter": { "branch": "master", "commit": "0ae494269acd469fbd896cf5d5a430dbbf4d4e95" },
"nvim-treesitter-context": { "branch": "master", "commit": "66531e825ab6c790ccf8837cfad2b9fab1b39d0b" },
"nvim-treesitter": { "branch": "master", "commit": "5822a8c6886f0238a315b57e5e96acdd74d04448" },
"nvim-treesitter-context": { "branch": "master", "commit": "cf618047619def57127fdd983f73e5bda373ccc0" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "2d6d3c7e49a24f6ffbbf7898241fefe9784f61bd" },
"nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" },
"nvim-ts-rainbow2": { "branch": "master", "commit": "60e34278a87b1a9f2ae59a67b4a062c5f6b9b8e7" },
"nvim-ts-autotag": { "branch": "main", "commit": "e254b306fb81ed69049cce526e7906150d73e0d1" },
"nvim-ts-rainbow2": { "branch": "master", "commit": "f3c70493bb23f83eee7b29aa6043c5caa38d111e" },
"nvim-web-devicons": { "branch": "master", "commit": "2a125024a137677930efcfdf720f205504c97268" },
"orgmode": { "branch": "master", "commit": "2737ef2be69b92fb58c6fb3861ca0bbb8f5d499e" },
"orgmode": { "branch": "master", "commit": "d9e48c40108e5e116494fce298a4df71f212bf5e" },
"overseer.nvim": { "branch": "master", "commit": "1a7d89cc1ae61199b227a15f077b3a9ca1da2dfa" },
"pantran.nvim": { "branch": "main", "commit": "42c4c1fba7cc86315e1f33eb2d31d99f7e96a9f6" },
"parinfer-rust": { "branch": "master", "commit": "3c769707ad3b18d530f696fe42a9d495139149ab" },
@ -76,12 +77,11 @@
"sniprun": { "branch": "master", "commit": "83791b87a8ede5275a2c060605bf1fec782205cc" },
"ssr.nvim": { "branch": "main", "commit": "e5768511518a397fa712f26389ba30d0404990de" },
"stickybuf.nvim": { "branch": "master", "commit": "fc75dc22d12e5446c72a0d5f067cd7a16b3d921a" },
"tabby.nvim": { "branch": "main", "commit": "8bbd8b15c15b69057260170355b8e7adcca1c11a" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "87dfaa9a9c251388cf4f01b9d4078c29d1fc8803" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" },
"telescope-symbols.nvim": { "branch": "master", "commit": "f2060117d965df4a626f068a4ebbd8ee051aa076" },
"telescope-tabs": { "branch": "master", "commit": "4e5c56ad020f2204d39c5d0a4775cc1bd2897041" },
"telescope.nvim": { "branch": "master", "commit": "37c526857807e9550bdc8649700d4ceb47750ef2" },
"telescope.nvim": { "branch": "master", "commit": "00cf15074a2997487813672a75f946d2ead95eb0" },
"todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" },
"toggleterm.nvim": { "branch": "main", "commit": "cf146a267a6a7db62b1e2aff40414b20081048a1" },
"treesj": { "branch": "main", "commit": "b1e2976c2d7ba922371cc7f3ab08b75136c27231" },

View File

@ -45,8 +45,10 @@ map('x', 'N', '"nN"[v:searchforward]', { expr = true, desc = 'Prev search result
map('o', 'N', '"nN"[v:searchforward]', { expr = true, desc = 'Prev search result' })
-- switching between buffers
map('n', ']b', '<cmd>bnext<CR>', { desc = 'Next buffer' })
map('n', '[b', '<cmd>bprevious<CR>', { desc = 'Previous buffer' })
if not util.has('nvim-cokeline') then
map('n', ']b', '<cmd>bnext<CR>', { desc = 'Next buffer' })
map('n', '[b', '<cmd>bprevious<CR>', { desc = 'Previous buffer' })
end
-- move between quickfix items
if not util.has('trouble.nvim') then

View File

@ -13,8 +13,8 @@ M.lsp_virtual_lines = true
-- Only 'bottom_pane', 'horizontal' or 'cursor' right now
M.telescope_layout = 'horizontal'
-- Whether to use tabby.nvim or heirline.nvim for Neovim's tabline
M.tabline_use_heirline = false
-- 'tabby' or 'cokeline'
M.tabline_provider = 'cokeline'
M.icons = {
notify = { -- also used for diagnostic signs

View File

@ -36,6 +36,11 @@ vim.api.nvim_create_autocmd('LspAttach', {
buffer = buffer,
})
end
-- Specific tweaks for some servers
if client.name == 'ruff_lsp' then
client.server_capabilities.hoverProvider = false
end
end,
})

View File

@ -52,6 +52,7 @@ return {
},
},
},
-- TODO: switch to pylyzer when it is more stable
pylsp = {
cmd = { servers_path .. '/pylsp/venv/bin/pylsp' },
settings = {
@ -149,13 +150,35 @@ return {
-- },
-- },
-- },
nil_ls = {
settings = {
['nil'] = {
formatting = {
command = { 'nixpkgs-fmt' },
},
},
},
},
ansiblels = { cmd = { servers_path .. '/ansiblels/node_modules/.bin/ansible-language-server', '--stdio' } },
bashls = { cmd = { servers_path .. '/bashls/node_modules/.bin/bash-language-server', 'start' } },
cssls = { cmd = { servers_path .. '/vscode/node_modules/.bin/vscode-css-language-server', '--stdio' } },
dockerls = { cmd = { servers_path .. '/dockerls/node_modules/.bin/docker-langserver', '--stdio' } },
emmet_ls = { cmd = { servers_path .. '/emmet_ls/node_modules/.bin/emmet-ls', '--stdio' } },
html = { cmd = { servers_path .. '/vscode/node_modules/.bin/vscode-html-language-server', '--stdio' } },
please = { cmd = { 'build_langserver', '--mode', 'stdio' } },
ruff_lsp = { cmd = { servers_path .. '/ruff_lsp/venv/bin/ruff-lsp' } },
sqlls = { cmd = { servers_path .. '/sqlls/node_modules/.bin/sql-language-server', 'up', '--method', 'stdio' } },
tsserver = { cmd = { servers_path .. '/tsserver/node_modules/.bin/typescript-language-server', '--stdio' } },
dhall_lsp_server = {},
gleam = {},
jsonnet_ls = {},
nickel_ls = {},
-- nixd = {},
-- pylyzer = {},
qmlls = {}, -- from qt6-qtdeclarative-dev in Alpine
rome = {},
taplo = {},
terraformls = {},
typst_lsp = {},
zls = {},
}

View File

@ -0,0 +1,119 @@
local colors = require('user.themes.' .. vim.g.colors_name .. '.colors')
local get_hex = require('cokeline.utils').get_hex
local mappings = require('cokeline.mappings')
local components = {
separator = {
text = function(buffer)
return buffer.index ~= 1 and '' or ''
end,
fg = colors.cyan,
truncation = { priority = 2 },
},
space = { text = ' ', truncation = { priority = 2 } },
devicon = {
text = function(buffer)
return (mappings.is_picking_focus() or mappings.is_picking_close()) and (buffer.pick_letter .. ' ') or (buffer.devicon.icon .. ' ')
end,
fg = function(buffer)
if mappings.is_picking_close() then
return buffer.is_focused and colors.yellow or colors.red
end
if mappings.is_picking_focus() then
return buffer.is_focused and colors.yellow or colors.blue
end
return buffer.devicon.color
end,
style = function()
return (mappings.is_picking_focus() or mappings.is_picking_close()) and 'bold,italic' or nil
end,
truncation = { priority = 3 },
},
unique_prefix = {
text = function(buffer)
return buffer.unique_prefix
end,
fg = get_hex('Comment', 'fg'),
style = 'italic',
truncation = { priority = 4, direction = 'left' },
},
filename = {
text = function(buffer)
return buffer.filename .. ' '
end,
style = function(buffer)
return buffer.is_focused and 'bold' or 'italic'
end,
truncation = { priority = 1, direction = 'left' },
},
file_readonly = {
text = function(buffer)
return (buffer.is_readonly or not vim.api.nvim_buf_get_option(buffer.number, 'modifiable')) and '' or ''
end,
fg = colors.red,
truncation = { priority = 3, direction = 'left' },
},
close_or_modified = {
text = function(buffer)
return buffer.is_modified and '' or ''
end,
fg = function(buffer)
return buffer.is_modified and colors.green or get_hex('Comment', 'fg')
end,
delete_buffer_on_left_click = true,
truncation = { priority = 3 },
},
}
local buffer_width = 24
local get_remaining_space = function(buffer)
local used_space = 0
for _, component in pairs(components) do
used_space = used_space + vim.fn.strwidth(
(type(component.text) == 'string' and component.text)
or (type(component.text) == 'function' and component.text(buffer))
)
end
return math.max(0, buffer_width - used_space)
end
local left_padding = {
text = function(buffer)
local remaining_space = get_remaining_space(buffer)
return string.rep(' ', remaining_space / 2 + remaining_space % 2)
end,
}
local right_padding = {
text = function(buffer)
local remaining_space = get_remaining_space(buffer)
return string.rep(' ', remaining_space / 2)
end,
}
return {
default_hl = {
fg = function(buffer)
return buffer.is_focused and get_hex('Normal', 'fg') or get_hex('Comment', 'fg')
end,
bg = 'NONE',
},
rendering = { max_buffer_width = buffer_width },
components = {
components.separator,
left_padding,
components.space,
components.devicon,
components.unique_prefix,
components.file_readonly,
components.filename,
right_padding,
components.close_or_modified,
},
rhs = {
{
text = '' .. vim.fn.fnamemodify(vim.fn.getcwd(), ':t') .. ' ',
fg = get_hex('TabLineSel', 'fg'),
bg = get_hex('TabLineSel', 'bg'),
truncation = { priority = 2 },
},
},
}

View File

@ -7,10 +7,7 @@ local vars = require('user.config.vars')
M.align = { provider = '%=' }
M.dummy = {
provider = '',
hl = { fg = 'blue' },
}
M.dummy = { provider = '', hl = { fg = 'blue' } }
local vi_mode = {
n = { name = 'NORMAL', color = 'green' },
@ -91,7 +88,7 @@ M.file_size = {
return ''
end
if fsize < 1024 then
return fsize .. suffix[1]
return fsize .. suffix[1] .. ' '
end
local i = math.floor((math.log(fsize) / math.log(1024)))
return string.format('%.2g%s ', fsize / math.pow(1024, i), suffix[i + 1])
@ -152,11 +149,10 @@ local file_icon = {
}
local file_name = {
provider = function(self)
local filename = vim.fn.fnamemodify(self.filename, ':p:t')
if filename == '' then
if self.filename == '' then
return '[No Name]'
end
return filename
return vim.fn.fnamemodify(self.filename, ':p:t')
end,
hl = function()
if vim.bo.modified then

View File

@ -1,6 +1,7 @@
local conditions = require('heirline.conditions')
local components = require('user.plugins.ui.heirline.components')
local excluded_buftype = { 'nofile', 'prompt', 'help', 'quickfix', 'terminal' }
local excluded_ft = {
'NvimTree',
'OverseerForm',
@ -21,8 +22,6 @@ local excluded_ft = {
'dapui_scopes',
}
local excluded_buftype = { 'nofile', 'prompt', 'help', 'quickfix', 'terminal' }
require('heirline').setup {
statusline = {
hl = function()

View File

@ -1,3 +1,5 @@
local tabline_provider = require('user.config.vars').tabline_provider
return {
{
'goolord/alpha-nvim',
@ -44,12 +46,26 @@ return {
},
{
'nanozuki/tabby.nvim',
enabled = vim.o.showtabline ~= 0 and not require('user.config.vars').tabline_use_heirline,
enabled = vim.o.showtabline ~= 0 and tabline_provider == 'tabby',
event = 'VeryLazy',
config = function()
require('user.plugins.ui.tabby')
end,
},
{
'willothy/nvim-cokeline',
enabled = vim.o.showtabline ~= 0 and tabline_provider == 'cokeline',
event = 'VeryLazy',
keys = {
{ '[b', '<Plug>(cokeline-focus-prev)', desc = 'Previous buffer' },
{ ']b', '<Plug>(cokeline-focus-next)', desc = 'Next buffer' },
{ '<localleader>b', function() require('cokeline.mappings').pick('focus') end, desc = 'Pick buffer' },
{ '<localleader>q', function() require('cokeline.mappings').pick('close') end, desc = 'Close picked buffer' },
},
opts = function()
return require('user.plugins.ui.cokeline')
end,
},
{
'rebelot/heirline.nvim',
event = 'UIEnter',

View File

@ -4,7 +4,7 @@ return {
lsp = {
-- `lsp_progress` builtin without progress bar
progress = {
enabled = true,
enabled = false,
format = {
'{data.progress.percentage}% ',
{ '{spinner} ', hl_group = 'NoiceLspProgressSpinner' },

View File

@ -7,40 +7,8 @@ return {
changedelete = { text = '-' },
untracked = { text = '+' },
},
signcolumn = true,
numhl = false,
linehl = false,
word_diff = false,
show_deleted = false,
watch_gitdir = {
interval = 1000,
follow_files = true,
},
attach_to_untracked = true,
current_line_blame = false,
current_line_blame_opts = {
delay = 1000,
virt_text = true,
virt_text_pos = 'right_align',
ignore_whitespace = false,
},
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
sign_priority = 6,
update_debounce = 100,
max_file_length = 40000,
preview_config = {
-- Options passed to nvim_open_win
border = require('user.config.vars').border,
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1,
},
yadm = { enable = false },
diff_opts = {
algorithm = 'myers', -- others: 'minimal', 'patience', 'histogram'
internal = true, -- If luajit is present
},
current_line_blame_opts = { virt_text_pos = 'right_align' },
preview_config = { border = require('user.config.vars').border },
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
@ -80,5 +48,6 @@ return {
map('n', '<leader>gD', function() gs.diffthis('~') end, { desc = 'Show diff against last commit' })
map('n', '<leader>gz', gs.toggle_deleted, { desc = 'Toggle showing deleted hunk' })
map({ 'o', 'x' }, 'ih', ':<C-u>Gitsigns select_hunk<CR>', { desc = 'Select git hunk' })
map('n', 'gh', function() gs.setqflist('attached') end, { desc = 'Show git hunks in attached buffers' })
end,
}

View File

@ -0,0 +1,8 @@
#!/bin/sh
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/ruff_lsp"
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
python3 -m venv "${server_path}"/venv
"${server_path}"/venv/bin/pip3 install -U pip
"${server_path}"/venv/bin/pip3 install -U ruff-lsp

View File

@ -1,7 +1,7 @@
status is-login; and replay "source /etc/profile"
status is-login; and umask {{ umask }}
for path in $XDG_BIN_HOME $GOPATH/bin $CARGO_HOME/bin $CABAL_DIR/bin $PNPM_HOME/bin $NPM_CONFIG_PREFIX/bin $KREW_ROOT/bin $XDG_CONFIG_HOME/emacs/bin
for path in $XDG_BIN_HOME $GOPATH/bin $CARGO_HOME/bin $CABAL_DIR/bin $PNPM_HOME/bin $KREW_ROOT/bin $HOME/.luarocks/bin
test -d $path && set -ga fish_user_paths $path
end

View File

@ -11,6 +11,20 @@
name: typos-cli
state: latest
# taplo package from Alpine's repo doesn't enable "lsp" feature
# Ref: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/42225
- name: packages | Install taplo
tags: [taplo, lspservers]
command:
cmd: /usr/bin/cargo install taplo-cli --locked --force --features native-tls,lsp
removes: /usr/bin/cargo
- name: packages | Install pylyzer
tags: [pylyzer, lspservers]
community.general.cargo:
name: pylyzer
state: latest
- name: packages | Install kubernix
tags: kubernix
community.general.cargo:
@ -35,12 +49,6 @@
cmd: /usr/bin/cargo install qsv --features all_full --locked --force
removes: /usr/bin/cargo
- name: packages | Install ttyper
tags: ttyper
community.general.cargo:
name: ttyper
state: latest
- name: packages | Install thokr
tags: thokr
community.general.cargo: