diff --git a/NOTES.md b/NOTES.md index c8a6b61..5f38446 100644 --- a/NOTES.md +++ b/NOTES.md @@ -2,6 +2,7 @@ ## Lsp +- K : hover documentation - grr : go to reference - gri : go to impl - grd : goto defn @@ -43,7 +44,7 @@ within insert mode, it's supported via blink C-y to accept C-space to open completions menu C-n/p to move up and down -C-k to open "documentation" +C-k to show signature help ## Fugutive workflow diff --git a/core/diagnostics.lua b/core/diagnostics.lua index 3de095e..e7ca15b 100644 --- a/core/diagnostics.lua +++ b/core/diagnostics.lua @@ -7,3 +7,17 @@ vim.diagnostic.config { virtual_lines = false, jump = { float = true }, } + +local function open_line_diagnostics() + vim.diagnostic.open_float { + scope = 'line', + focusable = true, + border = 'rounded', + source = 'always', + max_width = math.floor(vim.o.columns * 0.8), + max_height = math.floor(vim.o.lines * 0.5), + } +end + +vim.api.nvim_create_user_command('Diag', open_line_diagnostics, { desc = 'Show diagnostics for the current line' }) +vim.keymap.set('n', 'd', open_line_diagnostics, { desc = 'Show line [D]iagnostics' }) diff --git a/core/keymaps.lua b/core/keymaps.lua index 2c7d322..eca44cd 100644 --- a/core/keymaps.lua +++ b/core/keymaps.lua @@ -8,7 +8,25 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the left wind vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) -vim.keymap.set('n', '', 'close', { desc = 'Close window' }) +vim.keymap.set('n', '', function() + local wins = vim.tbl_filter(function(win) + return vim.api.nvim_win_get_config(win).relative == '' + end, vim.api.nvim_tabpage_list_wins(0)) + + if #wins > 1 then + vim.cmd('close') + else + local buffers = vim.tbl_filter(function(buf) + return vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted + end, vim.api.nvim_list_bufs()) + + if #buffers > 1 then + vim.cmd('bdelete') + else + vim.cmd('q') + end + end +end, { desc = 'Close split, buffer, or exit' }) vim.keymap.set('n', '', 'vsplit', { desc = 'Vertical split' }) vim.keymap.set('n', '', 'split', { desc = 'Horizontal split' }) vim.keymap.set('n', 'po', 'only', { desc = 'Only pane' }) diff --git a/core/options.lua b/core/options.lua index 221de7a..a58a8ae 100644 --- a/core/options.lua +++ b/core/options.lua @@ -21,7 +21,7 @@ vim.o.softtabstop = 4 vim.o.expandtab = true vim.o.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.listchars = { tab = ' ', trail = '·', nbsp = '␣' } vim.o.inccommand = 'split' vim.o.cursorline = true diff --git a/lazy-lock.json b/lazy-lock.json index 7533e37..4cefefe 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,27 +1,27 @@ { "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, - "conform.nvim": { "branch": "master", "commit": "dca1a190aa85f9065979ef35802fb77131911106" }, - "fidget.nvim": { "branch": "main", "commit": "889e2e96edef4e144965571d46f7a77bcc4d0ddf" }, - "gitsigns.nvim": { "branch": "main", "commit": "dd3f588bacbeb041be6facf1742e42097f62165d" }, + "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, + "fidget.nvim": { "branch": "main", "commit": "82404b196e73a00b1727a91903beef5ddc319d22" }, + "gitsigns.nvim": { "branch": "main", "commit": "25050e4ed39e628282831d4cbecb1850454ce915" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, - "kanagawa.nvim": { "branch": "master", "commit": "8ad3b4cdcc804b332c32db8f9743667e1bb82b99" }, - "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, - "loc.nvim": { "branch": "main", "commit": "c36814ad06a15d184d38e6f462aa15acc5fd45a2" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "0c2823e0418f3d9230ff8b201c976e84de1cb401" }, + "kanagawa.nvim": { "branch": "master", "commit": "bb85e4bfc8d89b0e62c8fa53ccdd13d12e2f77b3" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "loc.nvim": { "branch": "main", "commit": "9a6b0e1dd8fcc4e765cd859dd57b94f783bce231" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0a695750d747db1e7e70bcf0267ef8951c95fc83" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, - "mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" }, - "mini.nvim": { "branch": "main", "commit": "48555f1615f08c6318150aacb52bf7d61a5af798" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "84c75e7a7e443586f60508d12fc50f90d9aee14e" }, + "mason.nvim": { "branch": "main", "commit": "16ba83bfc8a25f52bb545134f5bee082b195c460" }, + "mini.nvim": { "branch": "main", "commit": "11afe78a10570fe1d0c7ed0b6fc2b5b19098cb45" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "ebd66767191714e008ce73b769518a763ff31bdc" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, - "nvim-lspconfig": { "branch": "master", "commit": "31026a13eefb20681124706a79fc1df6bf11ab27" }, + "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, + "nvim-lspconfig": { "branch": "master", "commit": "229b79051b380377664edc4cbd534930154921a1" }, "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, - "nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" }, + "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "f04ab730b8f9c6bf3f54a206d0dcddfd70c52d59" }, + "telescope.nvim": { "branch": "master", "commit": "7d324792b7943e4aa16ad007212e6acc6f9fe335" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, diff --git a/plugins/lsp.lua b/plugins/lsp.lua index 0c08eca..23c92ca 100644 --- a/plugins/lsp.lua +++ b/plugins/lsp.lua @@ -15,6 +15,8 @@ return { { 'j-hui/fidget.nvim', opts = {} }, }, config = function() + local capabilities = require('blink.cmp').get_lsp_capabilities() + vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) @@ -26,6 +28,7 @@ return { map('grn', vim.lsp.buf.rename, '[R]e[n]ame') map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + map('K', vim.lsp.buf.hover, 'Hover Documentation') local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client:supports_method('textDocument/documentHighlight', event.buf) then @@ -61,6 +64,7 @@ return { local servers = { clangd = {}, gopls = {}, + jdtls = {}, -- pyright = {}, -- rust_analyzer = {}, -- ts_ls = {}, @@ -107,6 +111,7 @@ return { require('mason-tool-installer').setup { ensure_installed = ensure_installed } for name, server in pairs(servers) do + server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) vim.lsp.config(name, server) vim.lsp.enable(name) end