Skip to content

Commit 0a1935e

Browse files
authored
Merge pull request #4 from MomoInSpace/snipet-editing
Snipet editing
2 parents ec50ce7 + a2f6b3d commit 0a1935e

18 files changed

+1169
-315
lines changed

Diff for: init.lua

+18
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,27 @@ require('plugin.nvim-cmp')
1313
require('plugin.treesitter')
1414
require('plugin.VimTeX')
1515

16+
-- nvim-lint Linter:
17+
require("plugin.nvim_lint")
18+
19+
-- Comments:
20+
require("plugin.comment")
21+
1622
-- All Keymaps should be defined here:
1723
require('basic.keymaps')
1824

25+
--LSP:
26+
require("plugin.mason")
27+
28+
-- Formatter:
29+
require("plugin.formatter")
30+
31+
-- Folding:
32+
require("plugin.nvim_ufo")
33+
34+
35+
36+
1937
-- Snippets from Luasnips:
2038
local latex_init = require('snippets.init')
2139
--latex_init()

Diff for: lua/basic/basic_nvim_settings.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--Make relative line numbers default.
22
vim.wo.number = true
3-
vim.wo.relativenumber = false
3+
vim.wo.relativenumber = true
44

55
-- Enable mouse mode.
66
vim.o.mouse = 'a'

Diff for: lua/basic/keymaps.lua

+48-46
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
11
-- All Keymaps Should be defined here:
2+
3+
-- Some Keymaps are defined in plugs.nvim-cmp
24

35
-- LuaSnips:
4-
local has_words_before = function()
5-
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
6-
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
7-
end
8-
9-
local luasnip = require("luasnip")
10-
local cmp = require("cmp")
11-
12-
cmp.setup({
13-
14-
-- ... Your other configuration ...
15-
16-
mapping = {
17-
18-
-- ... Your other mappings ...
19-
20-
["<Tab>"] = cmp.mapping(function(fallback)
21-
if cmp.visible() then
22-
cmp.select_next_item()
23-
elseif luasnip.expand_or_jumpable() then
24-
luasnip.expand_or_jump()
25-
elseif has_words_before() then
26-
cmp.complete()
27-
else
28-
fallback()
29-
end
30-
end, { "i", "s" }),
31-
32-
["<S-Tab>"] = cmp.mapping(function(fallback)
33-
if cmp.visible() then
34-
cmp.select_prev_item()
35-
elseif luasnip.jumpable(-1) then
36-
luasnip.jump(-1)
37-
else
38-
fallback()
39-
end
40-
end, { "i", "s" }),
41-
42-
-- ... Your other mappings ...
43-
},
44-
45-
-- ... Your other configuration ...
46-
})
47-
48-
vim.api.nvim_set_keymap("i", "<C-j>", "<Plug>luasnip-next-choice", {script = luasnip.choice_active()})
49-
vim.api.nvim_set_keymap("i", "<C-k>", "<Plug>luasnip-prev-choice", {script = luasnip.choice_active()})
6+
-- local has_words_before = function()
7+
-- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
8+
-- return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
9+
-- end
10+
--
11+
-- local luasnip = require("luasnip")
12+
-- local cmp = require("cmp")
13+
--
14+
-- cmp.setup({
15+
--
16+
-- -- ... Your other configuration ...
17+
--
18+
-- mapping = {
19+
--
20+
-- -- ... Your other mappings ...
21+
--
22+
-- ["<Tab>"] = cmp.mapping(function(fallback)
23+
-- if cmp.visible() then
24+
-- cmp.select_next_item()
25+
-- elseif luasnip.expand_or_jumpable() then
26+
-- luasnip.expand_or_jump()
27+
-- elseif has_words_before() then
28+
-- cmp.complete()
29+
-- else
30+
-- fallback()
31+
-- end
32+
-- end, { "i", "s" }),
33+
--
34+
-- ["<S-Tab>"] = cmp.mapping(function(fallback)
35+
-- if cmp.visible() then
36+
-- cmp.select_prev_item()
37+
-- elseif luasnip.jumpable(-1) then
38+
-- luasnip.jump(-1)
39+
-- else
40+
-- fallback()
41+
-- end
42+
-- end, { "i", "s" }),
43+
--
44+
-- -- ... Your other mappings ...
45+
-- },
46+
--
47+
-- -- ... Your other configuration ...
48+
-- })
49+
--
50+
-- vim.api.nvim_set_keymap("i", "<C-j>", "<Plug>luasnip-next-choice", {script = luasnip.choice_active()})
51+
-- vim.api.nvim_set_keymap("i", "<C-k>", "<Plug>luasnip-prev-choice", {script = luasnip.choice_active()})
5052

Diff for: lua/plugin/comment.lua

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
require("Comment").setup {
2+
3+
-- LHS of operator-pending mapping in NORMAL + VISUAL mode
4+
opleader = {
5+
-- line-comment keymap
6+
line = "gc",
7+
-- block-comment keymap
8+
block = "gb",
9+
},
10+
11+
-- Create basic (operator-pending) and extended mappings for NORMAL + VISUAL mode
12+
mappings = {
13+
14+
-- operator-pending mapping
15+
-- Includes:
16+
-- `gcc` -> line-comment the current line
17+
-- `gcb` -> block-comment the current line
18+
-- `gc[count]{motion}` -> line-comment the region contained in {motion}
19+
-- `gb[count]{motion}` -> block-comment the region contained in {motion}
20+
basic = true,
21+
22+
-- extra mapping
23+
-- Includes `gco`, `gcO`, `gcA`
24+
extra = true,
25+
26+
},
27+
28+
-- LHS of toggle mapping in NORMAL + VISUAL mode
29+
toggler = {
30+
-- line-comment keymap
31+
-- Makes sense to be related to your opleader.line
32+
line = "gcc",
33+
34+
-- block-comment keymap
35+
-- Make sense to be related to your opleader.block
36+
block = "gbc",
37+
},
38+
39+
-- Pre-hook, called before commenting the line
40+
-- Can be used to determine the commentstring value
41+
pre_hook = nil,
42+
43+
-- Post-hook, called after commenting is done
44+
-- Can be used to alter any formatting / newlines / etc. after commenting
45+
post_hook = nil,
46+
47+
-- Can be used to ignore certain lines when doing linewise motions.
48+
-- Can be string (lua regex)
49+
-- Or function (that returns lua regex)
50+
ignore = nil,
51+
}
52+
53+
local comment_ft = require "Comment.ft"
54+
comment_ft.set("lua", { "--%s", "--[[%s]]" })
55+
56+

Diff for: lua/plugin/formatter.lua

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
-- Config for formatter
2+
-- https://github.com/mhartington/formatter.nvim
3+
4+
-- Utilities for creating configurations
5+
local util = require "formatter.util"
6+
7+
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
8+
require("formatter").setup {
9+
-- Enable or disable logging
10+
logging = true,
11+
-- Set the log level
12+
log_level = vim.log.levels.WARN,
13+
-- All formatter configurations are opt-in
14+
filetype = {
15+
-- Formatter configurations for filetype "lua" go here
16+
-- and will be executed in order
17+
lua = {
18+
-- "formatter.filetypes.lua" defines default configurations for the
19+
-- "lua" filetype
20+
require("formatter.filetypes.lua").stylua,
21+
22+
-- You can also define your own configuration
23+
function()
24+
-- Supports conditional formatting
25+
if util.get_current_buffer_file_name() == "special.lua" then
26+
return nil
27+
end
28+
29+
-- Full specification of configurations is down below and in Vim help
30+
-- files
31+
return {
32+
exe = "stylua",
33+
args = {
34+
"--search-parent-directories",
35+
"--stdin-filepath",
36+
util.escape_path(util.get_current_buffer_file_path()),
37+
"--",
38+
"-",
39+
},
40+
stdin = true,
41+
}
42+
end
43+
},
44+
45+
-- Use the special "*" filetype for defining formatter configurations on
46+
-- any filetype
47+
["*"] = {
48+
-- "formatter.filetypes.any" defines default configurations for any
49+
-- filetype
50+
require("formatter.filetypes.any").remove_trailing_whitespace
51+
}
52+
}
53+
}
54+
vim.cmd([[
55+
augroup FormatAutogroup
56+
autocmd!
57+
autocmd BufWritePost * FormatWrite
58+
augroup END
59+
]])

Diff for: lua/plugin/mason.lua

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- MASON related configs:
2+
-- https://github.com/williamboman/mason.nvim
3+
4+
require("mason").setup({
5+
ui = {
6+
icons = {
7+
package_installed = "",
8+
package_pending = "",
9+
package_uninstalled = ""
10+
}
11+
}
12+
})
13+
require("mason-lspconfig").setup()

0 commit comments

Comments
 (0)