diff --git a/lsp/biome.lua b/lsp/biome.lua index 89735af..9ab2765 100644 --- a/lsp/biome.lua +++ b/lsp/biome.lua @@ -11,7 +11,7 @@ --- --- `biome` supports monorepos by default. It will automatically find the `biome.json` corresponding to the package you are working on, as described in the [documentation](https://biomejs.dev/guides/big-projects/#monorepo). This works without the need of spawning multiple instances of `biome`, saving memory. -local util = require 'lspconfig.util' +local utils = require('utils') ---@type vim.lsp.Config return { @@ -65,7 +65,7 @@ return { -- We know that the buffer is using Biome if it has a config file -- in its directory tree. local filename = vim.api.nvim_buf_get_name(bufnr) - biome_config_files = util.insert_package_json(biome_config_files, 'biomejs', filename) + biome_config_files = utils.insert_package_json(biome_config_files, 'biomejs', filename) local is_buffer_using_biome = vim.fs.find(biome_config_files, { path = filename, type = 'file', diff --git a/lsp/eslint.lua b/lsp/eslint.lua index 4770e1f..4493c36 100644 --- a/lsp/eslint.lua +++ b/lsp/eslint.lua @@ -1,30 +1,4 @@ -local utils = {} - -function utils.root_markers_with_field(root_files, new_names, field, fname) - local path = vim.fn.fnamemodify(fname, ':h') - local found = vim.fs.find(new_names, { path = path, upward = true }) - - for _, f in ipairs(found or {}) do - -- Match the given `field`. - for line in io.lines(f) do - if line:find(field) then - root_files[#root_files + 1] = vim.fs.basename(f) - break - end - end - end - - return root_files -end - -function utils.insert_package_json(root_files, field, fname) - return utils.root_markers_with_field( - root_files, - { 'package.json', 'package.json5' }, - field, - fname - ) -end +local utils = require('utils') --- @brief --- diff --git a/lsp/tailwindcss.lua b/lsp/tailwindcss.lua index 191161b..6f73ed0 100644 --- a/lsp/tailwindcss.lua +++ b/lsp/tailwindcss.lua @@ -1,30 +1,4 @@ -local utils = {} - -function utils.root_markers_with_field(root_files, new_names, field, fname) - local path = vim.fn.fnamemodify(fname, ':h') - local found = vim.fs.find(new_names, { path = path, upward = true }) - - for _, f in ipairs(found or {}) do - -- Match the given `field`. - for line in io.lines(f) do - if line:find(field) then - root_files[#root_files + 1] = vim.fs.basename(f) - break - end - end - end - - return root_files -end - -function utils.insert_package_json(root_files, field, fname) - return utils.root_markers_with_field( - root_files, - { 'package.json', 'package.json5' }, - field, - fname - ) -end +local utils = require('utils') ---@brief --- https://github.com/tailwindlabs/tailwindcss-intellisense diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua index 4b031e9..a73f749 100644 --- a/lua/core/keymaps.lua +++ b/lua/core/keymaps.lua @@ -50,6 +50,10 @@ map('n', '', 'h') map('n', '', 'l') map('n', '', 'j') map('n', '', 'k') +map('n', '', cmd('vertical resize -2')) +map('n', '', cmd('vertical resize +2')) +map('n', '', cmd('resize +2')) +map('n', '', cmd('resize -2')) -- Tab management map('n', ']t', cmd('tabnext')) @@ -113,3 +117,12 @@ map('n', 'K', vim.lsp.buf.hover) map('n', 'gd', vim.lsp.buf.definition) map('n', 'gr', vim.lsp.buf.references) map('n', '', vim.lsp.buf.signature_help) + +-- Git shortcut +vim.keymap.set('n', 'G', function() + vim.cmd('Gwrite') -- stage current worktree file + vim.cmd('Git') -- return to Fugitive status + vim.cmd('only') -- optional: close old diff panes + vim.cmd('normal! ]/') -- next file + vim.cmd('normal! dv') -- open vertical diff +end, { desc = 'Fugitive stage file and diff next' }) diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua deleted file mode 100644 index a206624..0000000 --- a/lua/lspconfig/util.lua +++ /dev/null @@ -1,23 +0,0 @@ -local M = {} - -function M.root_markers_with_field(root_files, new_names, field, fname) - local path = vim.fn.fnamemodify(fname, ':h') - local found = vim.fs.find(new_names, { path = path, upward = true }) - - for _, f in ipairs(found or {}) do - for line in io.lines(f) do - if line:find(field) then - root_files[#root_files + 1] = vim.fs.basename(f) - break - end - end - end - - return root_files -end - -function M.insert_package_json(root_files, field, fname) - return M.root_markers_with_field(root_files, { 'package.json', 'package.json5' }, field, fname) -end - -return M diff --git a/lua/utils.lua b/lua/utils.lua index 3799130..ae08676 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -21,4 +21,24 @@ function M.await(fn, timeout, interval) return { ok = ok or false, data = data } end +function M.root_markers_with_field(root_files, new_names, field, fname) + local path = vim.fn.fnamemodify(fname, ':h') + local found = vim.fs.find(new_names, { path = path, upward = true }) + + for _, file in ipairs(found or {}) do + for line in io.lines(file) do + if line:find(field) then + root_files[#root_files + 1] = vim.fs.basename(file) + break + end + end + end + + return root_files +end + +function M.insert_package_json(root_files, field, fname) + return M.root_markers_with_field(root_files, { 'package.json', 'package.json5' }, field, fname) +end + return M