Vscode snippets and other changes
This commit is contained in:
parent
fecc007494
commit
4b3c896343
15
dotfiles/neovim/lua/my/helpers/vscode.lua
Normal file
15
dotfiles/neovim/lua/my/helpers/vscode.lua
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
@ -47,7 +49,7 @@ function M.setup()
|
|||
else
|
||||
fallback()
|
||||
end
|
||||
end, {"i", "s"}),
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
|
@ -56,22 +58,33 @@ 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
|
||||
{name = 'luasnip'} -- snippets
|
||||
}, {{name = 'buffer'}})
|
||||
{ name = 'nvim_lsp' }, -- lsp completion
|
||||
{ name = 'luasnip' } -- snippets
|
||||
}, { { name = 'buffer' } })
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
7
dotfiles/neovim/lua/my/snippets.lua
Normal file
7
dotfiles/neovim/lua/my/snippets.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
require("luasnip.loaders.from_vscode").lazy_load({})
|
||||
end
|
||||
|
||||
return M
|
|
@ -40,7 +40,7 @@ function M.picker(opts)
|
|||
|
||||
for key, value in pairs(unicodeChars) do
|
||||
-- Name: char pair
|
||||
table.insert(results, {key, value})
|
||||
table.insert(results, { key, value })
|
||||
end
|
||||
|
||||
print(results)
|
||||
|
@ -50,7 +50,7 @@ function M.picker(opts)
|
|||
finder = finders.new_table {
|
||||
results = results,
|
||||
entry_maker = function(entry)
|
||||
return {value = entry, display = entry[1], ordinal = entry[1]}
|
||||
return { value = entry, display = entry[1], ordinal = entry[1] }
|
||||
end
|
||||
},
|
||||
sorter = conf.generic_sorter(opts),
|
||||
|
@ -67,7 +67,7 @@ function M.picker(opts)
|
|||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_put({selection.value[2]}, "", false, true)
|
||||
vim.api.nvim_put({ selection.value[2] }, "", false, true)
|
||||
vim.cmd("startinsert")
|
||||
end)
|
||||
return true
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
3
dotfiles/vscode-snippets/README.md
Normal file
3
dotfiles/vscode-snippets/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Vscode snippets
|
||||
|
||||
These are snippets usable both in vscode and neovim, defined in vscode format.
|
22
dotfiles/vscode-snippets/package.json
Normal file
22
dotfiles/vscode-snippets/package.json
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
59
dotfiles/vscode-snippets/snippets/purescript/deriving.json
Normal file
59
dotfiles/vscode-snippets/snippets/purescript/deriving.json
Normal 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"
|
||||
}
|
||||
}
|
37
dotfiles/vscode-snippets/snippets/purescript/imports.json
Normal file
37
dotfiles/vscode-snippets/snippets/purescript/imports.json
Normal 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"
|
||||
}
|
||||
}
|
64
dotfiles/vscode-snippets/snippets/purescript/other.json
Normal file
64
dotfiles/vscode-snippets/snippets/purescript/other.json
Normal 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",
|
||||
"-- | ```"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue