diff options
| -rw-r--r-- | nvim/lua/keymap.lua | 1 | ||||
| -rw-r--r-- | nvim/lua/plugins/lsp.lua | 61 | ||||
| -rwxr-xr-x | scripts/roll-die | 21 |
3 files changed, 64 insertions, 19 deletions
diff --git a/nvim/lua/keymap.lua b/nvim/lua/keymap.lua index b816776..5fff17b 100644 --- a/nvim/lua/keymap.lua +++ b/nvim/lua/keymap.lua @@ -11,6 +11,7 @@ end vim.keymap.set('n', 'gf', function() cmd_pcall(':e <cfile>') end, {noremap = true}) vim.keymap.set('n', "<Leader>q", function() vim.cmd(':botright cope') end) vim.keymap.set('n', "<Leader>l", function() cmd_pcall(':aboveleft lope') end) +vim.keymap.set('n', "<Leader>dk", function () vim.diagnostic.open_float() end) vim.keymap.set('n',"<Leader>k", function() vim.cmd("make") end) diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 217802a..b0b1ac6 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -3,8 +3,24 @@ local lspconfig = { lazy = false, dependencies = { 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig' + 'williamboman/mason-lspconfig.nvim' }, + config = function() + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client == nil then + return + end + if client.name == 'ruff' then + -- Disable hover in favor of BasedPyright + client.server_capabilities.hoverProvider = false + end + end, + desc = 'LSP: Disable hover capability from Ruff', + }) + end, keys = { { 'gd', @@ -16,7 +32,7 @@ local lspconfig = { }, { '<leader>r', - function () + function() vim.lsp.buf.rename() end, mode = 'n', @@ -27,20 +43,20 @@ local lspconfig = { function() vim.lsp.buf.format() end, - mode = {'n', 'v'}, + mode = { 'n', 'v' }, desc = "Format code" }, { '<leader>la', - function () + function() vim.lsp.buf.code_action() end, - mode = {'n', 's'}, + mode = { 'n', 's' }, desc = "Show code actions" }, { '<leader>lr', - function () + function() vim.lsp.buf.references() end, mode = 'n', @@ -48,7 +64,7 @@ local lspconfig = { }, { '<C-h>', - function () + function() vim.lsp.buf.signature_help() end, mode = 'i', @@ -59,7 +75,8 @@ local lspconfig = { local mason = { 'williamboman/mason.nvim', - opts = {} + opts = {}, + build = ":MasonUpdate" } local mason_lspconfig = { @@ -68,12 +85,22 @@ local mason_lspconfig = { 'williamboman/mason.nvim', }, opts = { + ensure_installed = { + "basedpyright", + "clangd", + "cssls", + "gopls", + "html", + "ruff", + "tsserver" + + }, handlers = { function(server_name) require('lspconfig')[server_name].setup({}) end }, - ["lua_ls"] = function () + ["lua_ls"] = function() require('lspconfig').lua_ls.setup({ settings = { Lua = { @@ -83,6 +110,22 @@ local mason_lspconfig = { } } }) + end, + ["basedpyright"] = function() + require('lspconfig').setup({ + settings = { + pyright = { + -- defer to ruff for import oranization + disableOrganizeImports = true, + }, + python = { + analysis = { + -- Ignore all files for analysis to exclusively use Ruff for linting + ignore = { '*' }, + }, + }, + }, + }) end } } diff --git a/scripts/roll-die b/scripts/roll-die index 8135b0b..6cb277a 100755 --- a/scripts/roll-die +++ b/scripts/roll-die @@ -6,17 +6,17 @@ from pathlib import Path import re -def roll_die(num_dice: int, dice_type: int, modifier: int) -> [int]: - rolls = [] - for i in range(num_dice): +def roll_die(num_dice: int, dice_type: int, modifier: int) -> list[int]: + rolls: list[int] = [] + for _ in range(num_dice): rolls.append(random.randint(1, dice_type) + modifier) return rolls -def parse_dice_notation(dice_notation) -> (int, int, int): +def parse_dice_notation(dice_notation: str) -> tuple[int, int, int]: # Define the regular expression pattern - pattern = re.compile(r'(\d+)d(\d+)([+-]\d+)?') + pattern = re.compile(r"(\d+)d(\d+)([+-]\d+)?") # Search the pattern in the dice notation string match = pattern.match(dice_notation) @@ -35,13 +35,13 @@ def parse_dice_notation(dice_notation) -> (int, int, int): return num_dice, dice_type, modifier -def summary(rolls: [int]) -> None: +def summary(rolls: list[int]) -> None: print(rolls) - print(f'Min: {min(rolls)}') - print(f'Max: {max(rolls)}') + print(f"Min: {min(rolls)}") + print(f"Max: {max(rolls)}") if len(rolls) > 1: - print(f'Total: {sum(rolls)}') - print(f'Avg: {sum(rolls)/len(rolls):.2f}') + print(f"Total: {sum(rolls)}") + print(f"Avg: {sum(rolls)/len(rolls):.2f}") def main(): @@ -61,6 +61,7 @@ def main(): num_die, die_type, modifier = parse_dice_notation(dice_notation) except ValueError as e: print(e) + sys.exit(1) rolls = roll_die(num_die, die_type, modifier) summary(rolls) |
