theres still more to do

This commit is contained in:
sadanslargehole 2024-03-12 01:28:22 -04:00
commit 641621a88a
No known key found for this signature in database
GPG key ID: B2E2F4A5161A7800
13 changed files with 447 additions and 0 deletions

17
init.lua Normal file
View file

@ -0,0 +1,17 @@
vim.g.mapleader = " "
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require"plugins"
require"setup"
require"keymap"
require"sets"

31
lua/keymap.lua Normal file
View file

@ -0,0 +1,31 @@
local tb = require("telescope.builtin")
-- find Files
vim.keymap.set("n", "<C-f>f", tb.find_files, {})
-- find Text
vim.keymap.set("n", "<C-f>t", tb.live_grep, {})
-- find Buffers
vim.keymap.set("n", "<C-f>b", tb.buffers, {})
-- find keyMaps
vim.keymap.set("n", "<C-f>m", tb.keymaps, {})
-- find Command
vim.keymap.set("n", "<C-f>c", tb.commands, {})
-- find Documentation
vim.keymap.set("n", "<C-f>d", tb.man_pages, {})
-- open tree
vim.keymap.set({ "i", "n" }, "<C-t>", vim.cmd.NvimTreeFocus, {})
-- move and copy lines
vim.keymap.set({ "i", "n" }, "<A-Up>", function()vim.api.nvim_feedkeys("ddkP", "x", false)end, {})
vim.keymap.set({ "i", "n" }, "<A-Down>", function()vim.api.nvim_feedkeys("ddp", "x", false)end, {})
vim.keymap.set({ "i", "n" }, "<A-S-Up>", function()vim.api.nvim_feedkeys("yyP", "x", false)end, {})
vim.keymap.set({ "i", "n" }, "<A-S-Down>", function()vim.api.nvim_feedkeys("yyp", "x", false)end, {})
-- on <C-Space> in normal, insert and start autoComp
vim.keymap.set("n", "<C-Space>", function()
vim.api.nvim_feedkeys("i", "m", false)
local key1 = vim.api.nvim_replace_termcodes("<C-Space>", true, false, true)
vim.api.nvim_feedkeys(key1, "m", false)
end, {})
vim.keymap.set({ "n", "i" }, "<A-F>", vim.cmd.Format, {})
vim.keymap.set({ "i", "n" }, "<C-\\>", vim.cmd.vsplit, {})
-- vscode fold and unfold
vim.keymap.set("n", "<C-[>","zc", {})
vim.keymap.set("n", "<C-]>", "zo", {})

89
lua/plugins.lua Normal file
View file

@ -0,0 +1,89 @@
local plugins = {
{
"williamboman/mason.nvim",
},
{
"williamboman/mason-lspconfig.nvim",
},
{
"neovim/nvim-lspconfig",
},
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
},
{
"abecodes/tabout.nvim",
lazy = false,
requires = {
"nvim-treesitter/nvim-treesitter",
"L3MON4D3/LuaSnip",
"hrsh7th/nvim-cmp",
},
event = "InsertCharPre", -- Set the event to 'InsertCharPre' for better compatibility
priority = 1000,
},
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
},
{
"numToStr/Comment.nvim",
opts = {
-- add any options here
},
lazy = false,
},
{
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true,
-- use opts = {} for passing setup options
-- this is equalent to setup({}) function
opts = {},
},
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
opts = {},
},
{
"mhartington/formatter.nvim",
},
{
"nvim-telescope/telescope.nvim",
tag = "0.1.5",
dependencies = { "nvim-lua/plenary.nvim" },
},
{
"hrsh7th/cmp-nvim-lsp",
},
{
"hrsh7th/nvim-cmp",
},
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
},
{
"saadparwaiz1/cmp_luasnip",
},
{
"nvim-tree/nvim-tree.lua",
},
{
"kevinhwang91/nvim-ufo",
dependencies = { "kevinhwang91/promise-async" },
},
--{
-- 'mfussenegger/nvim-lint'
--},
}
local opts = {}
require("lazy").setup(plugins, opts)

9
lua/sets.lua Normal file
View file

@ -0,0 +1,9 @@
vim.opt.rnu = true
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.smarttab = true
vim.opt.shiftround = true
vim.opt.shiftwidth = 4
vim.opt.smartcase = true
vim.opt.ignorecase = true
vim.opt.scrolloff = 4

18
lua/setup.lua Normal file
View file

@ -0,0 +1,18 @@
require("themesetup")
vim.cmd([[colorscheme tokyonight]])
require("mason").setup()
require("mason-lspconfig").setup()
require("setuplsp")
require("setupformat")
require("setuptree")
require("setuptreesitter")
-- Has to be setup after treesitter
require("setuptabout")
require("setupufo")
require("setupcomment")

8
lua/setupcomment.lua Normal file
View file

@ -0,0 +1,8 @@
require("Comment").setup({
toggler = {
line = "<C-/>",
},
opleader = {
line = "<C-/>",
},
})

66
lua/setupformat.lua Normal file
View file

@ -0,0 +1,66 @@
-- BY LANG
-- https://github.com/mhartington/formatter.nvim/tree/master/lua/formatter/filetypes
-- Utilities for creating configurations
local util = require("formatter.util")
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup({
-- Enable or disable logging
logging = true,
-- Set the log level
log_level = vim.log.levels.WARN,
-- All formatter configurations are opt-in
filetype = {
-- Formatter configurations for filetype "lua" go here
-- and will be executed in order
kotlin = {
require("formatter.filetypes.kotlin").ktlint,
function()
return {
exe = "ktlint",
args = {
"--stdin",
"--format",
"--log-level=none",
},
stdin = true,
}
end,
},
lua = {
-- "formatter.filetypes.lua" defines default configurations for the
-- "lua" filetype
require("formatter.filetypes.lua").stylua,
-- You can also define your own configuration
function()
-- Supports conditional formatting
if util.get_current_buffer_file_name() == "special.lua" then
return nil
end
-- Full specification of configurations is down below and in Vim help
-- files
return {
exe = "stylua",
args = {
"--search-parent-directories",
"--stdin-filepath",
util.escape_path(util.get_current_buffer_file_path()),
"--",
"-",
},
stdin = true,
}
end,
},
-- Use the special "*" filetype for defining formatter configurations on
-- any filetype
["*"] = {
-- "formatter.filetypes.any" defines default configurations for any
-- filetype
require("formatter.filetypes.any").remove_trailing_whitespace,
},
},
})

91
lua/setuplsp.lua Normal file
View file

@ -0,0 +1,91 @@
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local capabilities = require("cmp_nvim_lsp").default_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
--
require("lspconfig").kotlin_language_server.setup({
capabilities = capabilities,
})
--Java
require("lspconfig").java_language_server.setup({
capabilities = capabilities,
})
--Lua
require("lspconfig").lua_ls.setup({
capabilities = capabilities,
on_init = function(client)
local path = client.workspace_folders[1].name
if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then
return
end
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true)
},
})
end,
settings = {
Lua = {},
},
})
local luasnip = require("luasnip")
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
-- ['<C-u>'] = cmp.mapping.scroll_docs(-4), -- Up
-- ['<C-d>'] = cmp.mapping.scroll_docs(4), -- Down
-- C-b (back) C-f (forward) for snippet placeholder navigation.
['<C-Space>'] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
},
})

21
lua/setuptabout.lua Normal file
View file

@ -0,0 +1,21 @@
require("tabout").setup({
tabkey = "<Tab>", -- key to trigger tabout, set to an empty string to disable
backwards_tabkey = "<S-Tab>", -- key to trigger backwards tabout, set to an empty string to disable
act_as_tab = true, -- shift content if tab out is not possible
act_as_shift_tab = false, -- reverse shift content if tab out is not possible (if your keyboard/terminal supports <S-Tab>)
default_tab = "<C-t>", -- shift default action (only at the beginning of a line, otherwise <TAB> is used)
default_shift_tab = "<C-d>", -- reverse shift default action,
enable_backwards = true, -- well ...
completion = false, -- if the tabkey is used in a completion pum
tabouts = {
{ open = "'", close = "'" },
{ open = '"', close = '"' },
{ open = "`", close = "`" },
{ open = "(", close = ")" },
{ open = "[", close = "]" },
{ open = "{", close = "}" },
{ open = "{", close = "}" },
},
ignore_beginning = true, --[[ if the cursor is at the beginning of a filled element it will rather tab out than shift the content ]]
exclude = {}, -- tabout will ignore these filetypes
})

21
lua/setuptree.lua Normal file
View file

@ -0,0 +1,21 @@
-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- optionally enable 24-bit colour
vim.opt.termguicolors = true
local function myOnAttach(bufnr)
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- defaults
api.config.mappings.default_on_attach(bufnr)
vim.keymap.set("n", "<C-t>", api.tree.close, opts("close tree with ctrl+t"))
end
-- OR setup with some options
require("nvim-tree").setup({
on_attach = myOnAttach,
})

25
lua/setuptreesitter.lua Normal file
View file

@ -0,0 +1,25 @@
require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all"
ensure_installed = "all",
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
-- `false` will disable the whole extension
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
})

16
lua/setupufo.lua Normal file
View file

@ -0,0 +1,16 @@
vim.o.foldcolumn = "1" -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
-- Option 2: nvim lsp as LSP client
-- Tell the server the capability of foldingRange,
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually
-- in setuplsp.lua
require("ufo").setup()
--

35
lua/themesetup.lua Normal file
View file

@ -0,0 +1,35 @@
require("tokyonight").setup({
-- your configuration comes here
-- or leave it empty to use the default settings
style = "storm", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day`
light_style = "day", -- The theme is used when the background is set to light
transparent = true, -- Enable this to disable setting the background color
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in [Neovim](https://github.com/neovim/neovim)
styles = {
-- Style to be applied to different syntax groups
-- Value is any valid attr-list value for `:help nvim_set_hl`
comments = { italic = true },
keywords = { italic = true },
functions = {},
variables = {},
-- Background styles. Can be "dark", "transparent" or "normal"
sidebars = "dark", -- style for sidebars, see below
floats = "dark", -- style for floating windows
},
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors
hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
dim_inactive = false, -- dims inactive windows
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold
--- You can override specific color groups to use other groups or a hex color
--- function will be called with a ColorScheme table
---@param colors ColorScheme
on_colors = function(colors) end,
--- You can override specific highlights to use other groups or a hex color
--- function will be called with a Highlights and ColorScheme table
---@param highlights Highlights
---@param colors ColorScheme
on_highlights = function(highlights, colors) end,
})