Working on LSP and shit like that, Astro config is confusing, need to

learn it myself from scratch
This commit is contained in:
RingOfStorms (Joshua Bell) 2023-05-23 02:56:59 -05:00
parent 5e821a4d61
commit dc3e319f27
19 changed files with 400 additions and 18 deletions

1
cspell.json Normal file
View file

@ -0,0 +1 @@
{"language":"en","version":"0.2","words":["nvim","builtins","stylua","rustfmt","pendo","tanstack","ripgrep","Typeahead","overscan","autorun","mediatype","BIOINF","Transitioner","pkce","ilike","arrayify","arrayified","komodo","wezterm","gcloud","pbpaste"],"flagWords":[]}

View file

@ -18,7 +18,11 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("user", {})
require("lazy").setup("user", {
change_detection = {
enabled = false,
}
})
vim.cmd 'colorscheme material'

View file

@ -34,8 +34,6 @@ local mappings = {
["p"] = { '"*p', desc = "Paste from system clipboard" },
-- TODO L-c to close buffer
["<leader>gf"] = { ":OpenInGHFile <CR>", desc = "Open in github" },
["<leader>fs"] = {
function()
require("telescope.builtin").live_grep {
@ -51,15 +49,8 @@ local mappings = {
["<leader>st"] = { function() scratch ".ts" end, desc = "New ts scratch file" },
["<leader>sb"] = { function() scratch ".sh" end, desc = "New shell scratch file" },
["<leader>sj"] = { function() scratch ".js" end, desc = "New js scratch file" },
[""] = {
"<Esc>:m .+1<CR>==g",
desc = "Move the line up",
},
["˚"] = {
"<Esc>:m .-2<CR>==g",
desc = "Move the line down",
},
["<leader>r"] = { function() require("rest-nvim").run() end, desc = "Send http request" },
["<leader>Q"] = { ":qa<CR>", desc = "Quit all" },
["<leader>,"] = { name = " Misc Tools" },
["<leader>,c"] = { name = " Casing" },
@ -163,7 +154,24 @@ function set_mappings(map_table, base)
if package.loaded["which-key"] then which_key_register() end -- if which-key is loaded already, register
end
-- TODO load mappings from user plugins
for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath('config')..'/lua/user', [[v:val =~ '\.lua$']])) do
local uplugin = require('user.'..file:gsub('%.lua$', ''))
if (uplugin[1] ~= nil) then
if (uplugin.mappings ~= nil) then
for mode, keymaps in pairs(uplugin.mappings) do
-- Add new mode if not already existing
if (mappings[mode] == nil) then
mappings[mode] = {}
end
for key, value in pairs(keymaps) do
mappings[mode][key] = value;
end
end
end
end
end
set_mappings(mappings);

View file

@ -1,9 +1,30 @@
{
"SchemaStore.nvim": { "branch": "main", "commit": "15f37630d3abfb98607dd8e4625b731a8558b96d" },
"alpha-nvim": { "branch": "main", "commit": "1838ae926e8d49fe5330d1498ee8289ae2c340bc" },
"auto-save.nvim": { "branch": "main", "commit": "979b6c82f60cfa80f4cf437d77446d0ded0addf0" },
"gitsigns.nvim": { "branch": "main", "commit": "c18b7ca0b5b50596722f3a1572eb9b8eb520c0f1" },
"glow.nvim": { "branch": "advanced_window", "commit": "f1157d4cb7e46e830c72004e7e1adb81a1f9b04c" },
"lazy.nvim": { "branch": "main", "commit": "6610b15dfd76f7992423916e2b87f031881d7b25" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "c55d18f3947562e699d34d89681edbf9f0e250d3" },
"mason-null-ls.nvim": { "branch": "main", "commit": "54d702020bf94e4eefd357f0b738317af30217eb" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "c836e511e796d2b6a25ad9f164f5b25d8b9ff705" },
"mason.nvim": { "branch": "main", "commit": "08b2fd308e0107eab9f0b59d570b69089fd0b522" },
"material.nvim": { "branch": "main", "commit": "0c725897bc3d22c45fbf25a602002ee02f06f619" },
"neo-tree.nvim": { "branch": "v2.x", "commit": "20c2f2f5ba083bbb1e37b8bc3d590621434f31e9" },
"neodev.nvim": { "branch": "main", "commit": "2daabebac1b0b2ab7abba298c1a8f07a542866a6" },
"nui.nvim": { "branch": "main", "commit": "698e75814cd7c56b0dd8af4936bcef2d13807f3c" },
"null-ls.nvim": { "branch": "main", "commit": "77e53bc3bac34cc273be8ed9eb9ab78bcf67fa48" },
"nvim-dap": { "branch": "master", "commit": "56118cee6af15cb9ddba9d080880949d8eeb0c9f" },
"nvim-lspconfig": { "branch": "master", "commit": "1c13e529bd5683b54a39b633a560d2f00fcb25af" },
"nvim-treesitter": { "branch": "master", "commit": "f2778bd1a28b74adf5b1aa51aa57da85adfa3d16" },
"nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" },
"openingh.nvim": { "branch": "main", "commit": "374c081409dc238018cd986410f16190d8f9f680" },
"plenary.nvim": { "branch": "master", "commit": "9ac3e9541bbabd9d73663d757e4fe48a675bb054" },
"rest.nvim": { "branch": "main", "commit": "d8dc204e9f6fd930d9d1d709f0d19138f804431a" },
"rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" },
"telescope.nvim": { "branch": "master", "commit": "40c31fdde93bcd85aeb3447bb3e2a3208395a868" },
"vim-autoswap": { "branch": "master", "commit": "e587e4b14a605d8921942ba65a37583813289272" },
"which-key.nvim": { "branch": "main", "commit": "e271c28118998c93a14d189af3395812a1aa646c" }
}

View file

@ -47,7 +47,7 @@ dashboard.config.layout[1].val = vim.fn.max { 2, vim.fn.floor(vim.fn.winheight(0
dashboard.config.opts.noautocmd = true
return dashboard
end,
end,
config = function(_, opts)
require("alpha").setup(opts.config)

View file

@ -1,5 +1,5 @@
return {
"Pocco81/auto-save.nvim",
commit = "979b6c82f60cfa80f4cf437d77446d0ded0addf0", -- May 22, 2023
event = "User AstroFile",
event = "BufEnter",
}

5
lua/user/autoswap.lua Normal file
View file

@ -0,0 +1,5 @@
return {
"gioele/vim-autoswap",
commit = "e587e4b14a605d8921942ba65a37583813289272",
event = "BufEnter",
}

View file

@ -7,7 +7,9 @@ return {
},
cmd = "Glow",
mappings = {
["<leader>m"] = { name = " Markdown" },
["<leader>mp"] = { ":Glow <CR>", desc = "Markdown preview" },
n = {
["<leader>m"] = { "<Nop>", name = " Markdown" },
["<leader>mp"] = { ":Glow <CR>", desc = "Markdown preview" },
}
}
}

28
lua/user/lsp.lua Normal file
View file

@ -0,0 +1,28 @@
return {
{
"b0o/SchemaStore.nvim",
commit = "15f37630d3abfb98607dd8e4625b731a8558b96d",
},
{
"folke/neodev.nvim",
commit = "2daabebac1b0b2ab7abba298c1a8f07a542866a6",
opts = {
override = function(root_dir, library)
for _, astronvim_config in ipairs(astronvim.supported_configs) do
if root_dir:match(astronvim_config) then
library.plugins = true
break
end
end
vim.b.neodev_enabled = library.enabled
end,
},
},
{
"neovim/nvim-lspconfig",
commit = "1c13e529bd5683b54a39b633a560d2f00fcb25af",
dependencies = {
"williamboman/mason-lspconfig.nvim",
}
}
}

65
lua/user/mason.lua Normal file
View file

@ -0,0 +1,65 @@
return {
{
"williamboman/mason.nvim",
build = ":MasonUpdate", -- :MasonUpdate updates registry contents
commit = "08b2fd308e0107eab9f0b59d570b69089fd0b522",
cmd = {
"Mason",
"MasonInstall",
"MasonUninstall",
"MasonUninstallAll",
"MasonLog",
"MasonUpdate", -- AstroNvim extension here as well
"MasonUpdateAll", -- AstroNvim specific
},
opts = {
ui = {
icons = {
package_installed = "",
package_uninstalled = "",
package_pending = "",
},
},
},
--config = function(_, opts)
--require('mason').setup(opts)
--for _, plugin in ipairs { "mason-lspconfig", "mason-null-ls", "mason-nvim-dap" } do
-- pcall(require, plugin)
--end
--end
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim",
},
commit = "c55d18f3947562e699d34d89681edbf9f0e250d3",
cmd = { "LspInstall", "LspUninstall" },
opts = {
ensure_installed = { "lua_ls", "rust_analyzer", "tsserver", "pyright", "cssls", "cssmodules_ls" },
},
},
{
"jay-babu/mason-null-ls.nvim",
commit = "54d702020bf94e4eefd357f0b738317af30217eb",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"williamboman/mason.nvim",
"jose-elias-alvarez/null-ls.nvim",
},
opts = {
ensure_installed = { "prettier", "stylua", "black", "rust_fmt" },
},
},
{
"jay-babu/mason-nvim-dap.nvim",
commit = "c836e511e796d2b6a25ad9f164f5b25d8b9ff705",
dependencies = {
"williamboman/mason.nvim",
"mfussenegger/nvim-dap",
},
opts = {
ensure_installed = { "codelldb" },
},
},
}

46
lua/user/neo-tree.lua Normal file
View file

@ -0,0 +1,46 @@
return {
"nvim-neo-tree/neo-tree.nvim",
commit = "e5594d53986b34e584e8afe2ea6ad99d6f6d2105",
dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" },
cmd = "Neotree",
init = function() vim.g.neo_tree_remove_legacy_commands = true end,
pin = true,
tag = '2.56',
opts = {
auto_clean_after_session_restore = true,
close_if_last_window = true,
sources = { "filesystem" },
filesystem = {
follow_current_file = true,
group_empty_dirs = true,
filtered_items = {
visible = true,
hide_dotfiles = false,
hide_gitignored = false,
hide_by_name = {
".DS_Store",
},
},
},
nesting_rules = {
["ts"] = { ".cjs", ".cjs.map", ".d.ts", ".d.ts.map", ".js", ".js.map", ".mjs", ".mjs.map", ".test.ts" },
["tsx"] = { ".d.ts", ".d.ts.map", ".js;", ".js.map;", ".jsx;", ".jsx.map;", ".module.scss;", ".svg" },
["scss"] = { ".css", ".css.map" },
},
},
mappings = {
n = {
["<leader>e"] = { "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" },
["<leader>o"] = {
function()
if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd "p"
else
vim.cmd.Neotree "focus"
end
end,
desc = "Toggle Explorer Focus",
},
}
}
}

47
lua/user/null-ls.lua Normal file
View file

@ -0,0 +1,47 @@
-- npm install -g cspell@latest
local output = vim.fn.system {
"which",
"cspell",
}
if output == nil or output == "" then
-- if v:shell_error != 0 then
vim.fn.system {
"npm",
"install",
"-g",
"cspell@latest",
}
end
return {
"jose-elias-alvarez/null-ls.nvim",
commit = "77e53bc3bac34cc273be8ed9eb9ab78bcf67fa48",
opts = function(_, config)
-- config variable is the default definitions table for the setup function call
local null_ls = require "null-ls"
-- Check supported formatters and linters
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
config.sources = {
-- Set a formatter
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.rustfmt,
-- null_ls.builtins.code_actions.proselint, -- TODO looks interesting
null_ls.builtins.code_actions.cspell.with {
config = {
find_json = function() return vim.fn.findfile("cspell.json", vim.fn.environ().HOME .. "/.config/nvim/lua/user/;") end,
},
},
null_ls.builtins.diagnostics.cspell.with {
extra_args = { "--config", "~/.config/nvim/lua/user/cspell.json" },
},
}
config.update_in_insert = true
return config -- return final config table
end,
}

10
lua/user/open-github.lua Normal file
View file

@ -0,0 +1,10 @@
return {
"Almo7aya/openingh.nvim",
commit = "374c081409dc238018cd986410f16190d8f9f680",
event = "User AstroFile",
mappings = {
n = {
["<leader>gf"] = { ":OpenInGHFile <CR>", desc = "Open in github" },
},
},
}

5
lua/user/plenary.lua Normal file
View file

@ -0,0 +1,5 @@
return {
"nvim-lua/plenary.nvim",
commit = "9ac3e9541bbabd9d73663d757e4fe48a675bb054",
}

11
lua/user/rest-http.lua Normal file
View file

@ -0,0 +1,11 @@
return {
"rest-nvim/rest.nvim",
commit = "d8dc204e9f6fd930d9d1d709f0d19138f804431a",
event = "BufEnter *.http",
requires = { "nvim-lua/plenary.nvim" },
mappings = {
n = {
["<leader>r"] = { function() require("rest-nvim").run() end, desc = "Send http request" },
}
},
}

6
lua/user/rust-tools.lua Normal file
View file

@ -0,0 +1,6 @@
return {
"simrat39/rust-tools.nvim",
commit = "71d2cf67b5ed120a0e31b2c8adb210dd2834242f",
event = "BufEnter *.rs",
after = { "mason-lspconfig.nvim", "inlay-hints." },
}

42
lua/user/telescope.lua Normal file
View file

@ -0,0 +1,42 @@
return {
"nvim-telescope/telescope.nvim",
commit = "40c31fdde93bcd85aeb3447bb3e2a3208395a868",
dependencies = {
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable "make" == 1, build = "make" },
},
cmd = "Telescope",
opts = function()
local actions = require "telescope.actions"
local get_icon = require("astronvim.utils").get_icon
return {
defaults = {
prompt_prefix = string.format("%s ", get_icon "Search"),
selection_caret = string.format("%s ", get_icon "Selected"),
path_display = { "truncate" },
sorting_strategy = "ascending",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
},
vertical = {
mirror = false,
},
width = 0.87,
height = 0.80,
preview_cutoff = 120,
},
mappings = {
i = {
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
n = { ["q"] = actions.close },
},
},
}
end,
}

79
lua/user/treesitter.lua Normal file
View file

@ -0,0 +1,79 @@
return {
"nvim-treesitter/nvim-treesitter",
dependencies = { "windwp/nvim-ts-autotag", "JoosepAlviste/nvim-ts-context-commentstring" },
commit = "f2778bd1a28b74adf5b1aa51aa57da85adfa3d16",
build = ":TSUpdate",
event = "BufEnter",
cmd = {
"TSBufDisable",
"TSBufEnable",
"TSBufToggle",
"TSDisable",
"TSEnable",
"TSToggle",
"TSInstall",
"TSInstallInfo",
"TSInstallSync",
"TSModuleInfo",
"TSUninstall",
"TSUpdate",
"TSUpdateSync",
},
opts = {
-- "all",
ensure_installed = {
"http",
"json",
"bash",
"css",
"diff",
"dockerfile",
"dot",
"git_rebase",
"gitattributes",
"html",
"java",
"javascript",
"jq",
"jsdoc",
"json5",
"kotlin",
"latex",
"make",
"markdown",
"markdown_inline",
"nix",
"passwd",
"prisma",
"proto",
"python",
"regex",
"rst",
"rust",
"scss",
"sql",
"svelte",
"terraform",
"toml",
"tsx",
"typescript",
"vue",
"yaml",
},
-- auto_install = true,
highlight = {
enable = true,
disable = function(_, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 10000 end,
additional_vim_regex_highlighting = false,
},
incremental_selection = { enable = true },
ident = { enable = true },
autotag = { enable = true },
context_commentstring = { enable = true, enable_autocmd = false },
rainbow = {
enable = true,
extended_mode = true,
max_file_lines = nil,
},
},
}

View file

@ -15,4 +15,6 @@ vim.opt.breakindent = true
-- set tab length
vim.opt.tabstop = 2;
vim.opt.shiftwidth = 2;
-- split to the right or below always
vim.opt.splitbelow = true
vim.opt.splitright = true