Added files

Added after/ and lua/ scripts
This commit is contained in:
Ethan Smith-Coss 2023-04-20 14:42:48 +01:00
parent 0b75d1867a
commit 853e6b7ee5
Signed by: TheOnePath
GPG Key ID: 4E7D436CE1A0BAF1
10 changed files with 576 additions and 0 deletions

186
after/plugin/LSP.lua Normal file
View File

@ -0,0 +1,186 @@
local required = { 'mason', 'mason-lspconfig', 'lspconfig', 'cmp_nvim_lsp', 'fidget', 'neodev', 'mason-null-ls',
'mason-nvim-dap', 'dap', 'dapui' }
local modules = {}
for _, module in pairs(required) do
local ok, result = pcall(require, module)
if not ok then
print(module .. " is not install.")
return
end
modules[module] = result
end
local capabilities = modules['cmp_nvim_lsp'].default_capabilities()
modules['neodev'].setup()
modules["mason"].setup()
modules["mason-lspconfig"].setup {
ensure_installed = {"lua_ls"}
}
modules["mason-lspconfig"].setup_handlers {
function (server_name)
modules["lspconfig"][server_name].setup {
capabilities = capabilities
}
end,
["omnisharp"] = function ()
modules["lspconfig"]["omnisharp"].setup {
capabilities = capabilities,
on_attach = function (_,_)
local gr = vim.api.nvim_create_augroup("CS-OnAttach",{})
vim.api.nvim_create_autocmd({"BufWritePre"}, {
group = gr,
pattern = {"*.cs"},
desc = "(C#) Format before write",
callback = function ()
vim.lsp.buf.format()
end
}
)
end
}
end
}
modules['mason-null-ls'].setup({
ensure_installed = {},
automatic_installation = false,
automatic_setup = true,
})
modules['fidget'].setup{
text = {
spinner = "dots"
}
}
-- Built in diagnostic settings are also configured here
vim.diagnostic.config({
virtual_text = true,
signs = true,
underline = true,
update_in_insert = true,
severity_sort = false,
})
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, {text = icon, texthl = hl, numhl = hl})
end
local auGroupDiagHover = vim.api.nvim_create_augroup("Diagnostic_hover",{clear = true})
vim.api.nvim_create_autocmd("CursorHold",{
pattern = {"*"},
callback = function ()
vim.diagnostic.open_float(nil, {focus=false, scope="cursor"})
end,
group = auGroupDiagHover
})
-- ## DAP ## warning: here be dragons
modules['mason-nvim-dap'].setup({
automatic_setup = true,
})
modules['dapui'].setup({
icons = {
expanded = "",
collapsed = "",
current_frame = "",
},
expand_lines = vim.fn.has("nvim-0.7") == 1,
layouts = {
{
elements = {
-- Elements can be strings or table with id and size keys.
{ id = "scopes", size = 0.25 },
"breakpoints",
"stacks",
"watches",
},
size = 40, -- 40 columns
position = "left",
},
{
elements = {
"repl",
"console",
},
size = 0.25, -- 25% of total lines
position = "bottom",
},
},
controls = {
-- Requires Neovim nightly (or 0.8 when released)
enabled = true,
-- Display controls in this element
element = "repl",
icons = {
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "",
terminate = "",
},
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil.
}
})
modules['dap'].listeners.after.event_initialized["dapui_config"] = function()
modules['dapui'].open()
end
modules['dap'].listeners.before.event_terminated["dapui_config"] = function()
modules['dapui'].close()
end
modules['dap'].listeners.before.event_exited["dapui_config"] = function()
modules['dapui'].close()
end
-- Also configure lspsaga here.
-- Separate require check since we don't NEED lspsaga
local ok,lspsaga = pcall(require,"lspsaga")
if not ok then
return
end
-- Wrapping since some distros still don't ship nvim 0.8
if vim.fn.exists('+winbar') ~= 0 then
lspsaga.setup({
symbol_in_winbar = {
in_custom = false,
enable = true,
seperator = '>',
show_file = true,
click_support = false
},
diagnostic_header = { "", "", "", "" },
})
else
lspsaga.setup({
diagnostic_header = { "", "", "", "" },
})
end

View File

@ -0,0 +1,19 @@
require("cmp").register_source("luasnip", require("cmp_luasnip").new())
local cmp_luasnip = vim.api.nvim_create_augroup("cmp_luasnip", {})
vim.api.nvim_create_autocmd("User", {
pattern = "LuasnipCleanup",
callback = function ()
require("cmp_luasnip").clear_cache()
end,
group = cmp_luasnip
})
vim.api.nvim_create_autocmd("User", {
pattern = "LuasnipSnippetsAdded",
callback = function ()
require("cmp_luasnip").refresh()
end,
group = cmp_luasnip
})

113
after/plugin/completion.lua Normal file
View File

@ -0,0 +1,113 @@
-- Configure Completion
vim.opt.completeopt = {"menu","menuone","noselect"}
vim.opt.shortmess:append "c"
local ok, lspkind = pcall(require, "lspkind")
if not ok then
print("lspkind is not installed.")
return
end
lspkind.init()
local luasnip = require("luasnip")
local status, cmp = pcall(require, "cmp")
if not status then
print("nvim-cmp is not installed.")
return
end
if cmp == nil then
return
end
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup {
enabled = function ()
-- disable complete in comments
local context = require'cmp.config.context'
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == 'c' then
return true
else
return not context.in_treesitter_capture("comment")
and not context.in_syntax_group("Comment")
end
end,
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
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" }),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {
behavior = cmp.ConfirmBehavior.Insert,
select = true,
},
['<C-e>'] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping(
cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
},
sources = {
{name = "nvim_lua"},
{name = "nvim_lsp"},
{name = "path"},
{name = "luasnip"},
{
name = "buffer",
option = {
keyword_length = 5,
},
},
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
--- experimental = {
--- native_menu = false,
--- ghost_text = true,
--- },
formatting = {
format = lspkind.cmp_format {
mode = 'symbol_text',
menu = {
buffer = "[BUF]",
nvim_lsp = "[LSP]",
nvim_lua = "[API]",
path = "[PTH]",
luasnip = "[SNP]"
}
}
}
}

26
after/plugin/hls.lua Normal file
View File

@ -0,0 +1,26 @@
local ok, hls = pcall(require, 'hls')
if not ok then
print("hls is not installed.")
return
end
if hls == nil then
return
end
hls.setup {
cmd = { "haskell-language-server-wrapper", '--lsp' },
filetypes = { "haskell", "lhaskell" },
root_dir = function (filepath)
return (
vim.util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath)
or vim.util.root_pattern('*.cabal', 'package.yaml')(filepath)
)
end,
settings = {
haskell = {
formattingProvider = "ormolu"
}
},
single_file_support = true,
}

19
after/plugin/luasnips.lua Normal file
View File

@ -0,0 +1,19 @@
local ok, ls = pcall(require, 'luasnip')
if not ok then
print("NO SNIPS?")
return
end
-- local types = require "luasnip.util.types"
ls.config.set_config{
-- remember the last snippet
history = true,
-- make dynamic snippets update with typing
updateevents = "TextChanged,TextChangedI",
--Autosnippets:
enable_autosnippets = true,
}
require("luasnip/loaders/from_vscode").load()

View File

@ -0,0 +1,30 @@
local ok, telescope = pcall(require, 'telescope')
if not ok then
print("Telescope is not installed.")
return
end
telescope.setup {
-- configuration of Telescope go here
defaults = {
prompt_prefix = "🔎 ",
layout_config = {
height = 0.90,
prompt_position = "top",
preview_height = 15,
},
sorting_strategy = "ascending",
dynamic_preview_title = true,
},
pickers = { },
extensions = {
file_browser = {
grouped = true,
hijack_netrw = true,
dir_icon = "📁",
hidden = true,
}
}
}
telescope.load_extension "file_browser"

7
after/plugin/trouble.lua Normal file
View File

@ -0,0 +1,7 @@
local ok, trouble = pcall(require, 'trouble')
if not ok then
print("Looks like there was a little trouble...cus it's missing.")
return
end
trouble.setup {}

150
lua/plugins.lua Normal file
View File

@ -0,0 +1,150 @@
-- Grab Packer. (This should be OS agnostic)
-- by Iron-E and khuedoan on GitHub
local fn = vim.fn
local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if not vim.loop.fs_stat(install_path) then
if not fn.executable("git") == 1 then
print("Could not find git. Packer installation failed.")
return
end
Packer_bootstrap = fn.system({
'git',
'clone',
'--depth',
'1',
'https://github.com/wbthomason/packer.nvim',
install_path
})
vim.cmd 'packadd packer.nvim'
end
return require('packer').startup(function()
-- get Packer to manage itself
use 'wbthomason/packer.nvim'
use 'morhetz/gruvbox' -- Neovim editor theme (gruvbox MVP)
use 'williamboman/mason.nvim' -- better lspconfig interface
use {
'williamboman/mason-lspconfig.nvim',
requires = {
'neovim/nvim-lspconfig', -- Configurations for Nvim LSP
'williamboman/mason.nvim'
}
}
use {
'jay-babu/mason-null-ls.nvim',
requires = {
'jose-elias-alvarez/null-ls.nvim',
'williamboman/mason.nvim'
}
}
use {
'jay-babu/mason-nvim-dap.nvim',
requires = {
'williamboman/mason.nvim',
'mfussenegger/nvim-dap'
}
}
use {
'rcarriga/nvim-dap-ui',
requires = {
"mfussenegger/nvim-dap"
}
}
--[[ use {
'gleinir/lspsaga.nvim',-- Interact with LSP a little easier
branch='main'
}
--]]
-- learn this
use 'tpope/vim-surround'
-- differentiate brackets
use 'luochen1990/rainbow'
-- File tree
use 'preservim/nerdtree'
-- Distraction free writing
use 'junegunn/goyo.vim'
-- The Best Thing EVER
use 'vimwiki/vimwiki'
-- Eyecandy lbh
use 'bling/vim-airline'
-- better comments
use 'scrooloose/nerdcommenter'
-- Show colours
use 'ap/vim-css-color'
-- Add snippets
use 'honza/vim-snippets'
-- highlight matching html tags
use 'valloric/matchtagalways'
-- Syntax highlighting extension
use 'sheerun/vim-polyglot'
-- Autocomplete brackets and punctutation
use 'jiangmiao/auto-pairs'
-- Debug Adaptor Protocol (added for mason.nvim), and null-ls for linter and formatting
use 'mfussenegger/nvim-dap'
use 'jose-elias-alvarez/null-ls.nvim'
-- treesitter
use {
'nvim-treesitter/nvim-treesitter',
run = function()
local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
ts_update()
end,
}
-- Live Preview of MD
use {
"iamcco/markdown-preview.nvim",
run = "cd app && npm install",
setup = function() vim.g.mkdp_filetypes = { "markdown" } end,
ft = { "markdown" },
}
use 'rbgrouleff/bclose.vim'
-- Telescope dependencies and entry
use {
{
'nvim-telescope/telescope-fzf-native.nvim',
run = 'make',
},
{
'nvim-telescope/telescope.nvim',
branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
},
{
"nvim-telescope/telescope-file-browser.nvim"
},
}
use {
'hrsh7th/nvim-cmp',
'hrsh7th/cmp-buffer', -- completion source
'hrsh7th/cmp-path', -- completion source
'hrsh7th/cmp-nvim-lua', -- completion source
'hrsh7th/cmp-nvim-lsp', -- completion source
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
'onsails/lspkind.nvim'
}
use 'j-hui/fidget.nvim'
use {
"folke/trouble.nvim",
requires = "nvim-tree/nvim-web-devicons",
}
use 'folke/neodev.nvim'
if Packer_bootstrap then
require'packer'.sync()
require'packer'.compile()
end
end)

1
lua/presser Symbolic link
View File

@ -0,0 +1 @@
C:/Users/Ethan/Documents/ClosedLess/presser.nvim/lua/presser

25
lua/utils.lua Normal file
View File

@ -0,0 +1,25 @@
--- Thanks to Jarmos-san for the following Gist
-- https://gist.githubusercontent.com/Jarmos-san/c8bf40de6721b4a199799234be2c9f75/raw/1fdfb22233ad46fd7b23e4e450482758f52def42/utlis-map.lua
local M = {}
function M.map(mode, lhs, rhs, opts)
for i=1,string.len(mode) do
local options = { noremap = true }
if opts then
options = vim.tbl_extend("force", options, opts)
end
-- In Windows, `|` must be represented as `<bar>`.
if string.find(rhs, '|') then
local path_prefix = package.config:sub(1,1)
if path_prefix == '\\' then
rhs = rhs:gsub('|', "<bar>")
end
end
vim.api.nvim_set_keymap(string.sub(mode,i,i), lhs, rhs, options)
end
end
return M