initial commit
This commit is contained in:
commit
038a0d6940
1 changed files with 226 additions and 0 deletions
226
.config/nvim/init.lua
Normal file
226
.config/nvim/init.lua
Normal file
|
@ -0,0 +1,226 @@
|
|||
--vim.opt.termguicolors = true
|
||||
-- plugins
|
||||
require "paq" {
|
||||
"savq/paq-nvim"; -- Let Paq manage itself
|
||||
"nvim-lualine/lualine.nvim";
|
||||
{ 'kyazdani42/nvim-web-devicons', opt=true };
|
||||
|
||||
'neovim/nvim-lspconfig'; -- Collection of configurations for built-in LSP client
|
||||
'hrsh7th/nvim-cmp'; -- Autocompletion plugin
|
||||
'hrsh7th/cmp-nvim-lsp'; -- LSP source for nvim-cmp
|
||||
'saadparwaiz1/cmp_luasnip'; -- Snippets source for nvim-cmp
|
||||
'L3MON4D3/LuaSnip'; -- Snippets plugin
|
||||
|
||||
'nvim-treesitter/nvim-treesitter';
|
||||
|
||||
'windwp/nvim-autopairs';
|
||||
'tpope/vim-surround';
|
||||
'dhruvasagar/vim-table-mode';
|
||||
|
||||
'ap/vim-css-color';
|
||||
'elkowar/yuck.vim';
|
||||
}
|
||||
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all"
|
||||
ensure_installed = { "lua", "python" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- List of parsers to ignore installing (for "all")
|
||||
--ignore_install = { "javascript" },
|
||||
|
||||
highlight = {
|
||||
-- `false` will disable the whole extension
|
||||
enable = true,
|
||||
|
||||
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
|
||||
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
|
||||
-- the name of the parser)
|
||||
-- list of language that will be disabled
|
||||
--disable = { "c", "rust" },
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
|
||||
require'lualine'.setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'auto',
|
||||
component_separators = { left = '', right = ''},
|
||||
section_separators = { left = '', right = ''},
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {}
|
||||
}
|
||||
|
||||
-- require'lspconfig'.pylsp.setup{}
|
||||
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||
local servers = { 'clangd', 'rust_analyzer', 'pylsp', 'tsserver' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
-- on_attach = my_custom_on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
-- luasnip setup
|
||||
local luasnip = require 'luasnip'
|
||||
|
||||
-- nvim-cmp setup
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
['<S-Tab>'] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
require('nvim-autopairs').setup{}
|
||||
-- If you want insert `(` after select function or method item
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
local cmp = require('cmp')
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })
|
||||
)
|
||||
|
||||
-- add a lisp filetype (wrap my-function), FYI: Hardcoded = { "clojure", "clojurescript", "fennel", "janet" }
|
||||
--cmp_autopairs.lisp[#cmp_autopairs.lisp+1] = "racket"
|
||||
|
||||
vim.cmd [[
|
||||
function! s:isAtStartOfLine(mapping)
|
||||
let text_before_cursor = getline('.')[0 : col('.')-1]
|
||||
let mapping_pattern = '\V' . escape(a:mapping, '\')
|
||||
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
|
||||
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
|
||||
endfunction
|
||||
|
||||
inoreabbrev <expr> <bar><bar>
|
||||
\ <SID>isAtStartOfLine('\|\|') ?
|
||||
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
|
||||
inoreabbrev <expr> __
|
||||
\ <SID>isAtStartOfLine('__') ?
|
||||
\ '<c-o>:silent! TableModeDisable<cr>' : '__'
|
||||
]]
|
||||
|
||||
---
|
||||
local set = vim.opt
|
||||
|
||||
--vim.g.markdown_fenced_languages = ['css', 'html', 'python', 'bash=sh']
|
||||
set.wrap = true
|
||||
set.linebreak = true
|
||||
set.breakindent = true
|
||||
set.breakindentopt = {'shift:2', 'sbr'}
|
||||
set.showbreak = ' >'
|
||||
|
||||
set.number = true
|
||||
set.relativenumber = true
|
||||
set.encoding = "utf-8"
|
||||
|
||||
--set.filetype = true
|
||||
--set.filetype.plugin = true
|
||||
--set.filetype.indent = true
|
||||
|
||||
-- search
|
||||
set.hlsearch = true
|
||||
set.ignorecase = true
|
||||
set.smartcase = true
|
||||
|
||||
-- indentation
|
||||
set.smarttab = true
|
||||
set.expandtab = false
|
||||
set.copyindent = true
|
||||
set.preserveindent = true
|
||||
set.tabstop = 4
|
||||
set.shiftwidth = 4
|
||||
set.softtabstop = 0
|
||||
|
||||
local group = vim.api.nvim_create_augroup("WrapMarkdown", { clear = true })
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "markdown,txt",
|
||||
callback = function()
|
||||
vim.opt_local.colorcolumn = "100"
|
||||
vim.opt_local.textwidth = 100
|
||||
end,
|
||||
group = WrapMarkdown,
|
||||
})
|
||||
|
||||
vim.cmd [[
|
||||
let g:vim_markdown_folding_disabled=1
|
||||
]]
|
||||
|
||||
-- mapping
|
||||
local map = vim.api.nvim_set_keymap
|
||||
|
||||
map('n', '<Space>', '', {})
|
||||
map('n', '<Leader>n', ':bNext<CR>', {})
|
||||
vim.g.mapleader = ' '
|
||||
---
|
Loading…
Reference in a new issue