nvim: use ftplugin for filetypes

master
tiyn 1 year ago
parent 1eb2af2098
commit 3605c38993

@ -0,0 +1,7 @@
vim.api.nvim_create_autocmd({ 'VimLeave' },
{
command = '!cclear'
})
vim.o.textwidth = 80
vim.o.colorcolumn = "-0"

@ -0,0 +1,4 @@
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 100
vim.o.colorcolumn = "-0"

@ -0,0 +1,4 @@
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 100
vim.o.colorcolumn = "-0"

@ -0,0 +1,4 @@
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 100
vim.o.colorcolumn = "-0"

@ -0,0 +1,9 @@
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
callback = function() vim.o.foldenable = false end
})
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 100
vim.o.colorcolumn = "-0"

@ -0,0 +1,4 @@
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 80
vim.o.colorcolumn = "-0"

@ -0,0 +1,4 @@
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 80
vim.o.colorcolumn = "-0"

@ -0,0 +1,9 @@
vim.api.nvim_create_autocmd({ 'VimLeave' },
{
command = '!texclear %'
})
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 80
vim.o.colorcolumn = "-0"

@ -73,15 +73,28 @@ vim.o.foldenable = true
vim.o.conceallevel = 0 vim.o.conceallevel = 0
vim.g.markdown_folding = 1 vim.g.markdown_folding = 1
-- read files correctly
vim.filetype.add({
extension = {
c = 'c',
h = 'c',
html = 'html',
java = 'java',
js = 'javascript',
lua = 'lua',
md = 'markdown',
nim = 'nim',
py = 'python',
tex = 'tex',
}
})
-- load general mapped keys -- load general mapped keys
require('style') require('style')
-- load plugins (autoload all files in plugin folder) -- load plugins (autoload all files in plugin folder)
require('loadplugins') require('loadplugins')
-- set filetypes correctly by extension
require('autocmd')
-- load general mapped keys -- load general mapped keys
require('keymap') require('keymap')

@ -1,116 +0,0 @@
-- read files correctly
vim.filetype.add({
extension = {
c = 'c',
h = 'c',
html = 'html',
java = 'java',
js = 'javascript',
lua = 'lua',
md = 'markdown',
nim = 'nim',
py = 'python',
tex = 'tex',
}
})
-- settings for filetype: c
vim.api.nvim_create_autocmd({ 'VimLeave' },
{
pattern = { '*.c' },
command = '!cclear'
})
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'c' },
command = 'set colorcolumn=80'
})
-- settings for filetype: java
vim.api.nvim_create_autocmd({ 'FileType' },
{
pattern = { 'java' },
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'java' },
command = 'set colorcolumn=100'
})
-- settings for filetype: javascript
vim.api.nvim_create_autocmd({ 'FileType' },
{
pattern = { 'javascript' },
command = 'setlocal shiftwidth=2 softtabstop=2',
})
-- settings for filetype: lua
vim.api.nvim_create_autocmd({ 'FileType' },
{
pattern = { 'lua' },
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'lua' },
command = 'set colorcolumn=100'
})
-- settings for filetype: markdown
vim.api.nvim_create_autocmd({ 'FileType' },
{
pattern = { 'markdown' },
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'markdown' },
command = 'set colorcolumn=100'
})
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'markdown' },
command = 'set nofoldenable'
})
-- settings for filetype: nim
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'nim' },
command = 'set colorcolumn=80'
})
-- settings for filetype: python
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'python' },
command = 'set colorcolumn=80'
})
-- settings for filetype: tex
vim.api.nvim_create_autocmd({ 'VimLeave' },
{
pattern = { '*.tex' },
command = '!texclear %'
})
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
{
pattern = { 'tex' },
command = 'set colorcolumn=80'
})
Loading…
Cancel
Save