From 4a2cc0c04fab1b82c4680b1d031627796b30bb16 Mon Sep 17 00:00:00 2001 From: dpearre Date: Thu, 17 Oct 2024 14:24:37 -0700 Subject: [PATCH] Add keybindings for LSP info and add config options to python LSP and formatting --- init.lua | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index b241e04b..95a9186a 100644 --- a/init.lua +++ b/init.lua @@ -696,6 +696,10 @@ require('lazy').setup({ vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') end + + -- Me adding key bindings to show hover info and signature help for any language that supports it + map('gg', vim.lsp.buf.hover, 'Show hover info') + map('gs', vim.lsp.buf.signature_help, 'Show signature help') end, }) @@ -718,7 +722,17 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - pyright = {}, + pyright = { + settings = { + python = { + analysis = { + autoSearchPaths = true, + useLibraryCodeForTypes = true, -- Ensure Pyright pulls type information from libraries + }, + }, + }, + }, + phpactor = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -759,6 +773,14 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + + -- recommended for python by by https://www.youtube.com/watch?v=jWZ_JeLgDxU: + black = {}, + debugpy = {}, + flake8 = {}, + isort = {}, + mypy = {}, + pylint = {}, }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -812,7 +834,7 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { 'isort', 'black' }, -- -- You can use 'stop_after_first' to run the first available formatter from the list -- javascript = { "prettierd", "prettier", stop_after_first = true },