Kaynağa Gözat

venv selector and code format

Aleksei Dorokhov 3 ay önce
ebeveyn
işleme
032dc37c08
1 değiştirilmiş dosya ile 35 ekleme ve 0 silme
  1. 35 0
      init.lua

+ 35 - 0
init.lua

@@ -72,6 +72,27 @@ require("lazy").setup({
       opts = {},
     },
 
+    -- venv selector for python
+    {
+      "linux-cultist/venv-selector.nvim",
+      dependencies = {
+        "neovim/nvim-lspconfig",
+        {
+          "nvim-telescope/telescope.nvim",
+          branch = "0.1.x",
+          dependencies = { "nvim-lua/plenary.nvim" }
+        }, -- optional: you can also use fzf-lua, snacks, mini-pick instead.
+      },
+      ft = "python", -- Load when opening Python files
+      keys = {
+        { ",v", "<cmd>VenvSelect<cr>" }, -- Open picker on keymap
+      },
+      opts = { -- this can be an empty lua table - just showing below for clarity.
+        search = {}, -- if you add your own searches, they go here.
+        options = {} -- if you add plugin options, they go here.
+      },
+    },
+
     -- Autocompletion
     -- TODO: look into github.com/ms-jpq/coq_nvim
     {
@@ -355,3 +376,17 @@ cmp.setup {
 -- Do not yank when pasting over selected text
 --  "x" - visual mode
 vim.keymap.set("x", "p", "P", { silent = true })
+
+
+-- Auto format selected code
+vim.keymap.set("v", "<leader>f", function()
+  local start_pos = vim.api.nvim_buf_get_mark(0, "<")
+  local end_pos = vim.api.nvim_buf_get_mark(0, ">")
+
+  vim.lsp.buf.format({
+    range = {
+      ["start"] = { start_pos[1] - 1, start_pos[2] },
+      ["end"] = { end_pos[1] - 1, end_pos[2] },
+    },
+  })
+end)