1
Fork 0

Vscode snippets and other changes

This commit is contained in:
Matei Adriel 2022-08-05 20:11:10 +03:00
parent fecc007494
commit 4b3c896343
14 changed files with 366 additions and 147 deletions

View file

@ -0,0 +1,15 @@
local M = {}
function M.when(f)
if vim.g.vscode ~= nil then
f()
end
end
function M.unless(f)
if vim.g.vscode == nil then
f()
end
end
return M

View file

@ -6,6 +6,7 @@ function M.setup()
require("my.theme").setup()
require("my.options").setup()
require('my.keymaps').setup()
require('my.snippets').setup()
require('my.plugins').setup()
require("telescope.extensions.unicode").setupAbbreviations()
end

View file

@ -14,7 +14,24 @@ function M.setup()
local luasnip = require("luasnip")
local options = {
formatting = {format = lspkind.cmp_format({mode = "symbol"})},
window = {
completion = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
col_offset = -3,
side_padding = 0,
},
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. strings[1] .. " "
kind.menu = " (" .. strings[2] .. ")"
return kind
end,
},
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
@ -22,21 +39,6 @@ function M.setup()
end
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}),
-- ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}),
['<C-y>'] = cmp.config.disable,
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close()
}),
['<CR>'] = cmp.mapping.confirm({select = true}),
-- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings
['<C-Space>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert,
select = true
},
-- TODO: abstract booth of those away perhaps?
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
@ -56,7 +58,8 @@ function M.setup()
else
fallback()
end
end, {"i", "s"})
end, { "i", "s" }),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- lsp completion
@ -67,11 +70,21 @@ function M.setup()
cmp.setup(options)
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {sources = {{name = 'buffer'}}})
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}})
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end

View file

@ -1,30 +1,29 @@
local vscode = require("my.helpers.vscode")
local M = {}
function M.setup()
-- Other unconfigured plugins
require('nvim-autopairs').setup()
-- require("startup").setup()
require("presence"):setup({}) -- wtf does the : do here?
-- require("which-key").setup()
-- Plugins with their own configs:
require("my.plugins.vim-tmux-navigator").setup()
-- require("my.plugins.fzf-lua").setup()
-- require("my.plugins.nerdtree").setup()
require("my.plugins.treesitter").setup()
--
vscode.unless(function()
require("presence"):setup({})
require("my.plugins.dashboard").setup()
require("my.plugins.treesitter").setup()
require("my.plugins.cmp").setup()
require("my.plugins.lspconfig").setup()
require("my.plugins.null-ls").setup()
require("my.plugins.lualine").setup()
require("my.plugins.comment").setup()
require("my.plugins.nvim-tree").setup()
require("my.plugins.vimtex").setup()
require("my.plugins.lean").setup()
end)
require("my.plugins.vim-tmux-navigator").setup()
require("my.plugins.lualine").setup()
require("my.plugins.comment").setup()
require("my.plugins.telescope").setup()
require("my.plugins.vimux").setup()
-- require("my.plugins.idris").setup()
-- require("my.plugins.lh-brackets").setup()
require("my.plugins.lean").setup()
-- require("which-key").setup()
end
return M

View file

@ -0,0 +1,7 @@
local M = {}
function M.setup()
require("luasnip.loaders.from_vscode").lazy_load({})
end
return M

View file

@ -3,8 +3,6 @@ set -g prefix C-a
unbind C-b
bind C-a send-prefix
teh
# don't rename windows automatically
set-option -g allow-rename off

View file

@ -0,0 +1,3 @@
# Vscode snippets
These are snippets usable both in vscode and neovim, defined in vscode format.

View file

@ -0,0 +1,22 @@
{
"name": "adriels-snippets",
"engines": {
"vscode": "^1.11.0"
},
"contributes": {
"snippets": [
{
"language": ["purs", "purescript"],
"path": "./snippets/purescript/other.json"
},
{
"language": ["purs", "purescript"],
"path": "./snippets/purescript/imports.json"
},
{
"language": ["purs", "purescript"],
"path": "./snippets/purescript/deriving.json"
}
]
}
}

View file

@ -0,0 +1,59 @@
{
"Derive newtype instance": {
"prefix": "nderive",
"description": "Use newtype deriving on any typeclass",
"body": "derive newtype instance $0 $3 $2"
},
"Generate json instances": {
"prefix": "json",
"description": "Generate the deriving of the EncodeJson and DecodeJson typeclasses",
"body": [
"derive newtype instance EncodeJson $1",
"derive newtype instance DecodeJson $1"
]
},
"Generic": {
"prefix": "generic",
"description": "Generate the generic instance for a type",
"body": "derive instance Generic $1 _"
},
"Generic Show": {
"prefix": "gshow",
"description": "Generate generic show instances",
"body": [
"instance Show $1 where",
" show = genericShow"
]
},
"Generic Debug": {
"prefix": "gdebug",
"description": "Generate generic debug instances",
"body": [
"instance Debug $1 where",
" debug = genericDebug"
]
},
"Generic json": {
"prefix": "gjson",
"description": "Generate generic json instances",
"body": [
"instance EncodeJson $1 where",
" encodeJson = genericEncodeJson",
"instance DecodeJson $1 where",
" decodeJson = genericDecodeJson"
]
},
"Instance": {
"prefix": "instance",
"description": "Declare typeclass instance",
"body": [
"instance $2 $3 where",
" $0"
]
},
"Functor": {
"prefix": "functor",
"description": "Derive a Functor instance",
"body": "derive instance Functor $1$0"
}
}

View file

@ -0,0 +1,37 @@
{
"Tuple constructors": {
"prefix": "imptuple",
"description": "Import tuple constructors",
"body": "import Data.Tuple.Nested (type (/\\), (/\\))"
},
"Map": {
"prefix": "impmap",
"description": "Import Map module",
"body": "import Data.Map as Map"
},
"HashMap": {
"prefix": "imphashmap",
"description": "Import HashMap module",
"body": "import Data.HashMap as HashMap"
},
"FRP Event": {
"prefix": "impevent",
"description": "Import FRP.Event module",
"body": "import FRP.Event as E"
},
"List": {
"prefix": "implist",
"description": "Import List module",
"body": "import Data.List as List"
},
"Array": {
"prefix": "imparray",
"description": "import Array module",
"body": "import Data.Array as Array"
},
"AVar": {
"prefix": "impavar",
"description": "import AVar module",
"body": "import Effect.Aff.AVar as AV"
}
}

View file

@ -0,0 +1,64 @@
{
"Definition": {
"prefix": "definition",
"description": "Basic purescript definition",
"body": [
"$1 :: $2",
"$1 = $3"
]
},
"SProxy": {
"prefix": "sproxy",
"description": "Generate a proxy constant",
"body": [
"_$1 :: Proxy \"$1\"",
"_$1 = Proxy"
]
},
"Proxy": {
"prefix": "proxy",
"description": "Generate a proxy constant",
"body": [
"_$1 :: Proxy $1",
"_$1 = Proxy"
]
},
"Prop": {
"prefix": "prop",
"description": "Prop lens",
"body": [
"_$1 :: Lens' $2 $3",
"_$1 = prop (Proxy :: _ \"$1\")"
]
},
"Variant constructor": {
"prefix": "inj",
"description": "Generate a constructor for a variant an inline sproxy",
"body": [
"$1 :: forall r a. a -> Variant ( $1 :: a | r)",
"$1 = inj (SProxy :: SProxy \"$1\")"
]
},
"Full variant constructor": {
"prefix": "injf",
"description": "Generate a constructor for a variant with an external sproxy definition",
"body": [
"$1 :: forall r a. a -> Variant ( $1 :: a | r)",
"$1 = inj _$1",
"",
"_$1 :: Proxy \"$1\"",
"_$1 = Proxy"
]
},
"Example code": {
"prefix": "ex",
"description": "Provide example usage for some piece of code",
"body" : [
"-- |",
"-- | Ex:",
"-- | ```purs",
"-- | $0",
"-- | ```"
]
}
}

View file

@ -34,7 +34,7 @@
# editors
# vscodium
# vscode
vscode
# vim
# emacs
vimclip # use neovim anywhere
@ -45,7 +45,7 @@
signal-desktop
tdesktop # telegram for the desktop
# deluge
# zoom-us
zoom-us
# teams
# browsers

View file

@ -42,6 +42,7 @@ let
myConfig = ''
vim.g.lualineTheme = "${theme.neovim.lualineTheme}"
vim.opt.runtimepath:append("${paths.dotfiles}/neovim")
vim.opt.runtimepath:append("${paths.dotfiles}/vscode-snippets")
require("my.init").setup()
'';