Merge branch 'master' of ssh://git.joshuabell.xyz:3032/nvim
This commit is contained in:
commit
bd13aa8996
5 changed files with 141 additions and 5 deletions
|
@ -5,7 +5,7 @@ Goals:
|
|||
- Works with or without nix
|
||||
- LSP integration with the current project's settings if available
|
||||
|
||||
Old pre nix config: https://github.com/RingOfStorms/nvim/tree/40eadc9 for reference
|
||||
Old pre nix config: https://git.joshuabell.xyz/nvim/~files/40eadc9b714fa29c5b28aca49f77c1ea62141763 for reference
|
||||
|
||||
## Running
|
||||
|
||||
|
|
|
@ -208,12 +208,13 @@
|
|||
vscode-langservers-extracted # HTML/CSS/JSON/ESLint
|
||||
nodePackages.typescript-language-server
|
||||
tailwindcss-language-server
|
||||
pyright
|
||||
python312Packages.python-lsp-server
|
||||
rust-analyzer
|
||||
marksman # markdown
|
||||
taplo # toml
|
||||
yaml-language-server
|
||||
lemminx # xml
|
||||
ocamlPackages.ocaml-lsp # ocaml
|
||||
# Other
|
||||
typescript
|
||||
nodejs_20
|
||||
|
|
|
@ -3,7 +3,6 @@ return {
|
|||
event = "VeryLazy",
|
||||
opts = {
|
||||
-- change default options here
|
||||
keymaps = { basic = true },
|
||||
mode = "cursor",
|
||||
step_size = {
|
||||
vertical = 9,
|
||||
|
|
|
@ -190,8 +190,8 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
pyright = {
|
||||
-- python
|
||||
-- python
|
||||
pylsp = {
|
||||
capabilities = capabilities,
|
||||
},
|
||||
marksman = {
|
||||
|
@ -219,6 +219,10 @@ return {
|
|||
-- xml
|
||||
capabilities = capabilities,
|
||||
},
|
||||
ocamllsp = {
|
||||
-- ocaml
|
||||
capabilities = capabilities,
|
||||
}
|
||||
}
|
||||
if NIX then
|
||||
local lsp_servers = vim.tbl_keys(servers or {})
|
||||
|
|
132
lua/tools/scratch-files.lua
Normal file
132
lua/tools/scratch-files.lua
Normal file
|
@ -0,0 +1,132 @@
|
|||
local extensions = {
|
||||
"json",
|
||||
"sql",
|
||||
"html",
|
||||
"txt",
|
||||
"md",
|
||||
"lua",
|
||||
"css",
|
||||
"http",
|
||||
"js",
|
||||
"ts",
|
||||
"sh",
|
||||
"vim",
|
||||
"yaml",
|
||||
"toml",
|
||||
"conf",
|
||||
"nix",
|
||||
"rs",
|
||||
"py",
|
||||
"go",
|
||||
"rb",
|
||||
"java",
|
||||
"c",
|
||||
"cpp",
|
||||
"h",
|
||||
"hpp",
|
||||
"cs",
|
||||
"php",
|
||||
"pl",
|
||||
"r",
|
||||
"swift",
|
||||
"kt",
|
||||
"clj",
|
||||
"cljs",
|
||||
"hs",
|
||||
"elm",
|
||||
"erl",
|
||||
"ex",
|
||||
"exs",
|
||||
"scala",
|
||||
"groovy",
|
||||
"dart",
|
||||
"ts",
|
||||
"tsx",
|
||||
"jsx",
|
||||
"rs",
|
||||
"ml",
|
||||
}
|
||||
|
||||
local xdg_data_home = os.getenv("XDG_DATA_HOME") or (os.getenv("HOME") .. "/.local/share")
|
||||
local scratches_dir = xdg_data_home .. "/scratches"
|
||||
|
||||
-- Function to create a scratch file
|
||||
local function create_scratch_file(extension)
|
||||
vim.fn.mkdir(scratches_dir, "p")
|
||||
|
||||
local date = os.date("%Y_%m_%d_%H_%M_%S")
|
||||
local filename = string.format("%s/%s.%s", scratches_dir, date, extension)
|
||||
vim.cmd("edit " .. filename)
|
||||
end
|
||||
|
||||
-- Function to prompt for file extension
|
||||
local function prompt_for_extension()
|
||||
U.safeRequire("telescope", function()
|
||||
local pickers = require("telescope.pickers")
|
||||
local finders = require("telescope.finders")
|
||||
local sorters = require("telescope.config").values.generic_sorter
|
||||
local actions = require("telescope.actions")
|
||||
local action_state = require("telescope.actions.state")
|
||||
|
||||
pickers
|
||||
.new({
|
||||
layout_strategy = "vertical",
|
||||
layout_config = {
|
||||
width = 0.3,
|
||||
height = 0.4,
|
||||
prompt_position = "top",
|
||||
},
|
||||
}, {
|
||||
prompt_title = "Choose or enter file extension",
|
||||
finder = finders.new_table({
|
||||
results = extensions,
|
||||
entry_maker = function(entry)
|
||||
return {
|
||||
value = entry,
|
||||
display = entry,
|
||||
ordinal = entry,
|
||||
}
|
||||
end,
|
||||
}),
|
||||
sorter = sorters({}),
|
||||
attach_mappings = function(prompt_bufnr, map)
|
||||
local function on_select()
|
||||
local selection = action_state.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
create_scratch_file(selection.value)
|
||||
end
|
||||
|
||||
map("i", "<CR>", on_select)
|
||||
map("n", "<CR>", on_select)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
:find()
|
||||
end, function()
|
||||
local extension = vim.fn.input("Enter file extension: ")
|
||||
create_scratch_file(extension)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Set up the keymap
|
||||
U.keymaps({
|
||||
{
|
||||
"<leader>fsw",
|
||||
function()
|
||||
require("telescope.builtin").live_grep({
|
||||
search_dirs = { scratches_dir },
|
||||
})
|
||||
end,
|
||||
desc = "Find Words in Scratches",
|
||||
},
|
||||
{
|
||||
"<leader>fss",
|
||||
function()
|
||||
require("telescope.builtin").find_files({
|
||||
search_dirs = { scratches_dir },
|
||||
})
|
||||
end,
|
||||
desc = "Find Scratches",
|
||||
},
|
||||
{ "<leader>ss", prompt_for_extension, mode = { "n", "v", "x" }, desc = "Create a scratch file" },
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue