diff --git a/README.md b/README.md index 1fcbeb1..db356e2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/flake.nix b/flake.nix index 6200d45..a4703fb 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/lua/plugins/cinnamon_scroll.lua b/lua/plugins/cinnamon_scroll.lua index cd962fa..b99b6de 100644 --- a/lua/plugins/cinnamon_scroll.lua +++ b/lua/plugins/cinnamon_scroll.lua @@ -3,7 +3,6 @@ return { event = "VeryLazy", opts = { -- change default options here - keymaps = { basic = true }, mode = "cursor", step_size = { vertical = 9, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 42e5cf8..2b8e5dd 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -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 {}) diff --git a/lua/tools/scratch-files.lua b/lua/tools/scratch-files.lua new file mode 100644 index 0000000..14a5639 --- /dev/null +++ b/lua/tools/scratch-files.lua @@ -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", "", on_select) + map("n", "", 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({ + { + "fsw", + function() + require("telescope.builtin").live_grep({ + search_dirs = { scratches_dir }, + }) + end, + desc = "Find Words in Scratches", + }, + { + "fss", + function() + require("telescope.builtin").find_files({ + search_dirs = { scratches_dir }, + }) + end, + desc = "Find Scratches", + }, + { "ss", prompt_for_extension, mode = { "n", "v", "x" }, desc = "Create a scratch file" }, +})