Skip to content

Commit 7833ff2

Browse files
committed
tweak for myself
1. remove tree-sitter, report error for latex files 2. remove autoformatter, I don't like it 3. add vimtex 4. add some snippets that I used to 5. change some keybindings
1 parent 3338d39 commit 7833ff2

3 files changed

Lines changed: 110 additions & 76 deletions

File tree

init.lua

Lines changed: 87 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ P.S. You can delete this when you're done too. It's your config now! :)
8787
-- Set <space> as the leader key
8888
-- See `:help mapleader`
8989
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
90-
vim.g.mapleader = ' '
91-
vim.g.maplocalleader = ' '
90+
vim.g.mapleader = ','
91+
vim.g.maplocalleader = ','
9292

9393
-- Set to true if you have a Nerd Font installed and selected in the terminal
9494
vim.g.have_nerd_font = false
@@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
102102
vim.o.number = true
103103
-- You can also add relative line numbers, to help with jumping.
104104
-- Experiment for yourself to see if you like it!
105-
-- vim.o.relativenumber = true
105+
vim.o.relativenumber = true
106106

107107
-- Enable mouse mode, can be useful for resizing splits for example!
108108
vim.o.mouse = 'a'
@@ -129,7 +129,7 @@ vim.o.ignorecase = true
129129
vim.o.smartcase = true
130130

131131
-- Keep signcolumn on by default
132-
vim.o.signcolumn = 'yes'
132+
vim.o.signcolumn = 'no'
133133

134134
-- Decrease update time
135135
vim.o.updatetime = 250
@@ -172,6 +172,7 @@ vim.o.confirm = true
172172
-- Clear highlights on search when pressing <Esc> in normal mode
173173
-- See `:help hlsearch`
174174
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
175+
vim.keymap.set('n', '<leader>n', '<Cmd>set invnumber invrelativenumber<cr>')
175176

176177
-- Diagnostic keymaps
177178
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
@@ -716,6 +717,10 @@ require('lazy').setup({
716717
local ensure_installed = vim.tbl_keys(servers or {})
717718
vim.list_extend(ensure_installed, {
718719
'stylua', -- Used to format Lua code
720+
'pylsp',
721+
'clangd',
722+
'texlab',
723+
'rust_analyzer',
719724
})
720725
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
721726

@@ -736,46 +741,46 @@ require('lazy').setup({
736741
end,
737742
},
738743

739-
{ -- Autoformat
740-
'stevearc/conform.nvim',
741-
event = { 'BufWritePre' },
742-
cmd = { 'ConformInfo' },
743-
keys = {
744-
{
745-
'<leader>f',
746-
function()
747-
require('conform').format { async = true, lsp_format = 'fallback' }
748-
end,
749-
mode = '',
750-
desc = '[F]ormat buffer',
751-
},
752-
},
753-
opts = {
754-
notify_on_error = false,
755-
format_on_save = function(bufnr)
756-
-- Disable "format_on_save lsp_fallback" for languages that don't
757-
-- have a well standardized coding style. You can add additional
758-
-- languages here or re-enable it for the disabled ones.
759-
local disable_filetypes = { c = true, cpp = true }
760-
if disable_filetypes[vim.bo[bufnr].filetype] then
761-
return nil
762-
else
763-
return {
764-
timeout_ms = 500,
765-
lsp_format = 'fallback',
766-
}
767-
end
768-
end,
769-
formatters_by_ft = {
770-
lua = { 'stylua' },
771-
-- Conform can also run multiple formatters sequentially
772-
-- python = { "isort", "black" },
773-
--
774-
-- You can use 'stop_after_first' to run the first available formatter from the list
775-
-- javascript = { "prettierd", "prettier", stop_after_first = true },
776-
},
777-
},
778-
},
744+
-- { -- Autoformat
745+
-- 'stevearc/conform.nvim',
746+
-- event = { 'BufWritePre' },
747+
-- cmd = { 'ConformInfo' },
748+
-- keys = {
749+
-- {
750+
-- '<leader>f',
751+
-- function()
752+
-- require('conform').format { async = true, lsp_format = 'fallback' }
753+
-- end,
754+
-- mode = '',
755+
-- desc = '[F]ormat buffer',
756+
-- },
757+
-- },
758+
-- opts = {
759+
-- notify_on_error = false,
760+
-- format_on_save = function(bufnr)
761+
-- -- Disable "format_on_save lsp_fallback" for languages that don't
762+
-- -- have a well standardized coding style. You can add additional
763+
-- -- languages here or re-enable it for the disabled ones.
764+
-- local disable_filetypes = { c = true, cpp = true }
765+
-- if disable_filetypes[vim.bo[bufnr].filetype] then
766+
-- return nil
767+
-- else
768+
-- return {
769+
-- timeout_ms = 500,
770+
-- lsp_format = 'fallback',
771+
-- }
772+
-- end
773+
-- end,
774+
-- formatters_by_ft = {
775+
-- lua = { 'stylua' },
776+
-- -- Conform can also run multiple formatters sequentially
777+
-- -- python = { "isort", "black" },
778+
-- --
779+
-- -- You can use 'stop_after_first' to run the first available formatter from the list
780+
-- -- javascript = { "prettierd", "prettier", stop_after_first = true },
781+
-- },
782+
-- },
783+
-- },
779784

780785
{ -- Autocompletion
781786
'saghen/blink.cmp',
@@ -799,12 +804,13 @@ require('lazy').setup({
799804
-- `friendly-snippets` contains a variety of premade snippets.
800805
-- See the README about individual language/framework/plugin snippets:
801806
-- https://github.com/rafamadriz/friendly-snippets
802-
-- {
803-
-- 'rafamadriz/friendly-snippets',
804-
-- config = function()
805-
-- require('luasnip.loaders.from_vscode').lazy_load()
806-
-- end,
807-
-- },
807+
{
808+
'rafamadriz/friendly-snippets',
809+
config = function()
810+
require('luasnip.loaders.from_vscode').lazy_load()
811+
require('luasnip.loaders.from_vscode').load({ paths = { '~/.config/nvim/snippets/' } })
812+
end,
813+
},
808814
},
809815
opts = {},
810816
},
@@ -894,7 +900,10 @@ require('lazy').setup({
894900
-- Load the colorscheme here.
895901
-- Like many other themes, this one has different styles, and you could load
896902
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
897-
vim.cmd.colorscheme 'tokyonight-night'
903+
vim.cmd.colorscheme 'vim'
904+
905+
-- You can configure highlights by doing something like:
906+
vim.cmd.hi 'Comment gui=none'
898907
end,
899908
},
900909

@@ -938,31 +947,31 @@ require('lazy').setup({
938947
-- Check out: https://github.com/echasnovski/mini.nvim
939948
end,
940949
},
941-
{ -- Highlight, edit, and navigate code
942-
'nvim-treesitter/nvim-treesitter',
943-
build = ':TSUpdate',
944-
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
945-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
946-
opts = {
947-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
948-
-- Autoinstall languages that are not installed
949-
auto_install = true,
950-
highlight = {
951-
enable = true,
952-
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
953-
-- If you are experiencing weird indenting issues, add the language to
954-
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
955-
additional_vim_regex_highlighting = { 'ruby' },
956-
},
957-
indent = { enable = true, disable = { 'ruby' } },
958-
},
959-
-- There are additional nvim-treesitter modules that you can use to interact
960-
-- with nvim-treesitter. You should go explore a few and see what interests you:
961-
--
962-
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
963-
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
964-
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
965-
},
950+
-- { -- Highlight, edit, and navigate code
951+
-- 'nvim-treesitter/nvim-treesitter',
952+
-- build = ':TSUpdate',
953+
-- main = 'nvim-treesitter.configs', -- Sets main module to use for opts
954+
-- -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
955+
-- opts = {
956+
-- ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
957+
-- -- Autoinstall languages that are not installed
958+
-- auto_install = true,
959+
-- highlight = {
960+
-- enable = true,
961+
-- -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
962+
-- -- If you are experiencing weird indenting issues, add the language to
963+
-- -- the list of additional_vim_regex_highlighting and disabled languages for indent.
964+
-- additional_vim_regex_highlighting = { 'ruby' },
965+
-- },
966+
-- indent = { enable = true, disable = { 'ruby' } },
967+
-- },
968+
-- -- There are additional nvim-treesitter modules that you can use to interact
969+
-- -- with nvim-treesitter. You should go explore a few and see what interests you:
970+
-- --
971+
-- -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
972+
-- -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
973+
-- -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
974+
-- },
966975

967976
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
968977
-- init.lua. If you want these files, they are in the repository, so you can just download them and
@@ -990,6 +999,7 @@ require('lazy').setup({
990999
-- Or use telescope!
9911000
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
9921001
-- you can continue same window with `<space>sr` which resumes last telescope search
1002+
{ 'lervag/vimtex' },
9931003
}, {
9941004
ui = {
9951005
-- If you are using a Nerd Font: set icons to an empty table which will use the
@@ -1012,5 +1022,6 @@ require('lazy').setup({
10121022
},
10131023
})
10141024

1025+
10151026
-- The line beneath this is called `modeline`. See `:help modeline`
10161027
-- vim: ts=2 sts=2 sw=2 et

snippets/latex.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"article": {
3+
"prefix": "bA",
4+
"body": "\\documentclass[UTF8,fontset=windows,10pt,a4paper]{ctexart}\n\\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}\n\\usepackage{graphicx}\n\\title{$1}\n\\begin{document}\n$0\n\\end{document}",
5+
"description": "regular article"
6+
},
7+
"verbatim": {
8+
"prefix": "bV",
9+
"body": "\\begin{verbatim}\n$0\n\\end{verbatim}",
10+
"description": "verbatim environment"
11+
}
12+
}

snippets/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "my-snippets",
3+
"contributes": {
4+
"snippets": [
5+
{
6+
"language": ["plaintex", "tex"],
7+
"path": "./latex.json"
8+
}
9+
]
10+
}
11+
}

0 commit comments

Comments
 (0)