mirror of
https://github.com/davegallant/nix-config
synced 2025-08-07 00:58:16 +00:00
Add luasnip
This commit is contained in:
@@ -330,15 +330,16 @@ in
|
|||||||
extraConfig = "lua require('init')";
|
extraConfig = "lua require('init')";
|
||||||
|
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = with pkgs.vimPlugins; [
|
||||||
completion-nvim
|
|
||||||
/* copilot-vim */
|
/* copilot-vim */
|
||||||
cmp-nvim-lsp
|
cmp-nvim-lsp
|
||||||
cmp-path
|
cmp-path
|
||||||
cmp-treesitter
|
cmp-treesitter
|
||||||
|
friendly-snippets
|
||||||
gitlinker-nvim
|
gitlinker-nvim
|
||||||
gitsigns-nvim
|
gitsigns-nvim
|
||||||
gruvbox-nvim
|
gruvbox-nvim
|
||||||
lualine-nvim
|
lualine-nvim
|
||||||
|
luasnip
|
||||||
nvim-cmp
|
nvim-cmp
|
||||||
nvim-lspconfig
|
nvim-lspconfig
|
||||||
nvim-tree-lua
|
nvim-tree-lua
|
||||||
@@ -347,7 +348,6 @@ in
|
|||||||
nvim-web-devicons
|
nvim-web-devicons
|
||||||
packer-nvim
|
packer-nvim
|
||||||
plenary-nvim
|
plenary-nvim
|
||||||
supertab
|
|
||||||
telescope-fzy-native-nvim
|
telescope-fzy-native-nvim
|
||||||
vim-commentary
|
vim-commentary
|
||||||
vim-markdown
|
vim-markdown
|
||||||
|
@@ -68,10 +68,6 @@ vim.api.nvim_set_keymap(
|
|||||||
{ silent = true, noremap = true }
|
{ silent = true, noremap = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Use tab as trigger keys
|
|
||||||
vim.cmd([[imap <tab> <Plug>(completion_smart_tab)]])
|
|
||||||
vim.cmd([[imap <s-tab> <Plug>(completion_smart_s_tab)]])
|
|
||||||
|
|
||||||
-- Remember line number
|
-- Remember line number
|
||||||
vim.cmd([[au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]])
|
vim.cmd([[au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]])
|
||||||
|
|
||||||
@@ -117,19 +113,52 @@ vim.api.nvim_set_keymap("n", "<space>", "za", { silent = true, noremap = true })
|
|||||||
-- packer {{{1 -------------------------------------------------------------------
|
-- packer {{{1 -------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
require("packer").startup(function()
|
require("packer").startup(function()
|
||||||
-- use({ "ms-jpq/coq.artifacts", branch = "artifacts" })
|
-- use({ "ms-jpq/coq.artifacts", branch = "artifacts" })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- lsp {{{1 -------------------------------------------------------------------
|
-- lsp {{{1 -------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
require'cmp'.setup {
|
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
|
||||||
|
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
{ name = 'treesitter' },
|
{ name = 'treesitter' },
|
||||||
}
|
},
|
||||||
|
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" }),
|
||||||
|
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local lspconfig = require "lspconfig"
|
local lspconfig = require "lspconfig"
|
||||||
@@ -151,6 +180,13 @@ lspconfig.gopls.setup({
|
|||||||
|
|
||||||
lspconfig.sumneko_lua.setup({
|
lspconfig.sumneko_lua.setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { 'vim' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -188,6 +224,10 @@ vim.cmd([[autocmd BufWritePre *.go lua vim.lsp.buf.formatting_sync()]])
|
|||||||
vim.cmd([[autocmd BufWritePre *.rb lua vim.lsp.buf.formatting_sync()]])
|
vim.cmd([[autocmd BufWritePre *.rb lua vim.lsp.buf.formatting_sync()]])
|
||||||
vim.cmd([[autocmd BufWritePre *.nix lua vim.lsp.buf.formatting_sync()]])
|
vim.cmd([[autocmd BufWritePre *.nix lua vim.lsp.buf.formatting_sync()]])
|
||||||
|
|
||||||
|
|
||||||
|
require'luasnip'.filetype_extend("go", {"go"})
|
||||||
|
require'luasnip'.filetype_extend("ruby", {"rails"})
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Plugins {{{1 ---------------------------------------------------------------
|
-- Plugins {{{1 ---------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -258,9 +298,6 @@ vim.api.nvim_set_keymap("n", "<leader>n", "<cmd>NvimTreeToggle<cr>", { noremap =
|
|||||||
vim.api.nvim_set_keymap("n", "<leader>r", "<cmd>NvimTreeRefresh<cr>", { noremap = true })
|
vim.api.nvim_set_keymap("n", "<leader>r", "<cmd>NvimTreeRefresh<cr>", { noremap = true })
|
||||||
vim.api.nvim_set_keymap("n", "<leader>nf", "<cmd>NvimTreeFindFile<cr>", { noremap = true })
|
vim.api.nvim_set_keymap("n", "<leader>nf", "<cmd>NvimTreeFindFile<cr>", { noremap = true })
|
||||||
|
|
||||||
-- completion-nvim
|
|
||||||
vim.cmd([[autocmd BufEnter * lua require'completion'.on_attach()]])
|
|
||||||
|
|
||||||
--Set colorscheme
|
--Set colorscheme
|
||||||
vim.o.termguicolors = true
|
vim.o.termguicolors = true
|
||||||
vim.cmd([[colorscheme gruvbox]])
|
vim.cmd([[colorscheme gruvbox]])
|
||||||
|
Reference in New Issue
Block a user