CRAG666 / code_runner.nvim

Neovim plugin.The best code runner you could have, it is like the one in vscode but with super powers, it manages projects like in intellij but without being slow
MIT License
534 stars 38 forks source link

using new filetype #89

Closed azinsharaf closed 11 months ago

azinsharaf commented 1 year ago

i can use the code runner on py files successfully. The issue is i have a python file with pyt extension (from a third party application i support) and i can't run it via code runner. How can i define a new file extension (pyt here) in the config instead of filetype? fyi, I have added the file type in neovim polish function and pyright lsp recognizes it as python correctly.

code runner config:

return {
  "CRAG666/code_runner.nvim",
  enabled = true,
  event = "VeryLazy",
  init = function() require("which-key").register({ ["<leader>r"] = { name = "Code Runner" } }, { mode = "n" }) end,
  opts = {
    mode = "float", --"toggle", "float", "tab", "toggleterm" 
    focus = true,
    term = {
      position = "bot",
      size = 25,
    },
    float = {
      border = "single",
      height = 0.7,
      width = 0.5,
    },
    filetype = {
      python = "C:/Users/asharaf/AppData/Local/ESRI/conda/envs/arcgispro-py3-clone/python.exe"
      -- python = "C:/Python27/ArcGIS10.8/python.exe"
    },
  },
  keys = {
    { "<leader>rr", "<cmd>RunCode<cr>",    desc = "Run Code" },
    { "<leader>rf", "<cmd>RunFile<cr>",    desc = "Run File" },
    -- { "<leader>rft", "<cmd>RunFile tab<cr>", desc = "Run File Tab" },
    { "<leader>rp", "<cmd>RunProject<cr>", desc = "Run Project" },
    { "<leader>rc", "<cmd>RunClose<cr>",   desc = "Run Close" },
    -- { "<leader>crf", "<cmd>CRFiletype<cr>", desc = "Open Json supported files" },
    -- { "<leader>crp", "<cmd>CRProject<cr>", desc = "Open Json list of projects" },
  },
}

neovim new filetype config:

return {
  polish = function()
    -- Set up custom filetypes
    vim.filetype.add {
      extension = {
        pyt = "python",
      },
    --   filename = {
    --     ["Foofile"] = "fooscript",
    --   },
    --   pattern = {
    --     ["~/%.config/foo/.*"] = "fooscript",
    --   },
    }
  end,
}
azinsharaf commented 11 months ago

it is working fine now, so i close this.